Update README and code documentation.
Showing
2 changed files
with
7 additions
and
3 deletions
1 | # Rivets.js | 1 | # Rivets.js |
2 | 2 | ||
3 | Rivets.js is a declarative data binding facility that plays well with existing frameworks such as [Backbone.js](http://backbonejs.org), [Spine.js](http://spinejs.com) and [Stapes.js](http://hay.github.com/stapes/). It aims to be lightweight (1.2KB minified and gzipped), extensible, and configurable to work with any event-driven model. | 3 | Rivets.js is a declarative data binding facility that plays well with existing frameworks such as [Backbone.js](http://backbonejs.org), [Spine.js](http://spinejs.com) and [Stapes.js](http://hay.github.com/stapes/). It aims to be lightweight (1.4KB minified and gzipped), extensible, and configurable to work with any event-driven model. |
4 | 4 | ||
5 | --- | 5 | --- |
6 | 6 | ||
... | @@ -43,8 +43,12 @@ Rivets.js is model interface-agnostic, meaning it can work with any event-driven | ... | @@ -43,8 +43,12 @@ Rivets.js is model interface-agnostic, meaning it can work with any event-driven |
43 | rivets.configure({ | 43 | rivets.configure({ |
44 | adapter: { | 44 | adapter: { |
45 | subscribe: function(obj, keypath, callback) { | 45 | subscribe: function(obj, keypath, callback) { |
46 | obj.on('change:' + keypath, function(m, v) { callback(v) }); | 46 | callback.wrapped = function(m, v) { callback(v) }; |
47 | obj.on('change:' + keypath, callback.wrapped); | ||
47 | }, | 48 | }, |
49 | unsubscribe: function(obj, keypath, callback) { | ||
50 | obj.off('change:' + keypath, callback.wrapped); | ||
51 | } | ||
48 | read: function(obj, keypath) { | 52 | read: function(obj, keypath) { |
49 | return obj.get(keypath); | 53 | return obj.get(keypath); |
50 | }, | 54 | }, | ... | ... |
... | @@ -129,7 +129,7 @@ eventBinding = (event) -> (el, bind, unbind) -> | ... | @@ -129,7 +129,7 @@ eventBinding = (event) -> (el, bind, unbind) -> |
129 | unbindEvent el, event, unbind if unbind | 129 | unbindEvent el, event, unbind if unbind |
130 | 130 | ||
131 | # Returns an attribute binding routine for the specified attribute. This is what | 131 | # Returns an attribute binding routine for the specified attribute. This is what |
132 | # `registerBinding` falls back to when there is no routine for the binding type. | 132 | # is used when there are no matching routines for an identifier. |
133 | attributeBinding = (attr) -> (el, value) -> | 133 | attributeBinding = (attr) -> (el, value) -> |
134 | if value then el.setAttribute attr, value else el.removeAttribute attr | 134 | if value then el.setAttribute attr, value else el.removeAttribute attr |
135 | 135 | ... | ... |
-
Please register or sign in to post a comment