3246edc1 by Michael Richards

Update the README with simplified subscribe/unsubscribe implementations in the example adapter.

1 parent 3f1df5a3
...@@ -43,11 +43,10 @@ Rivets.js is model interface-agnostic, meaning it can work with any event-driven ...@@ -43,11 +43,10 @@ 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 callback.wrapped = function(m, v) { callback(v) }; 46 obj.on('change:' + keypath, callback);
47 obj.on('change:' + keypath, callback.wrapped);
48 }, 47 },
49 unsubscribe: function(obj, keypath, callback) { 48 unsubscribe: function(obj, keypath, callback) {
50 obj.off('change:' + keypath, callback.wrapped); 49 obj.off('change:' + keypath, callback);
51 }, 50 },
52 read: function(obj, keypath) { 51 read: function(obj, keypath) {
53 return obj.get(keypath); 52 return obj.get(keypath);
......