Created
April 21, 2013 13:29
-
-
Save elentok/5429584 to your computer and use it in GitHub Desktop.
For future reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //= require components/rivets/lib/rivets | |
| // ---------------------------------- | |
| attributes: {}, | |
| set: function (key, value) { | |
| if (this.attributes[key] !== value) { | |
| this.attributes[key] = value; | |
| this.events.triggerEvent("change:" + key, {key: key, value: value}); | |
| } | |
| }, | |
| get: function (key) { | |
| return this.attributes[key]; | |
| }, | |
| // ---------------------------------- | |
| rivets.formatters.t = function(key) { | |
| return I18n.t(key); | |
| }; | |
| rivets.configure({ | |
| adapter: { | |
| subscribe: function(obj, keypath, callback) { | |
| var events = {}; | |
| events['change:' + keypath] = callback; | |
| obj.events.on(events); | |
| }, | |
| unsubscribe: function(obj, keypath, callback) { | |
| var events = {}; | |
| events['change:' + keypath] = callback; | |
| obj.events.off(events); | |
| }, | |
| read: function(obj, keypath) { | |
| return obj.get(keypath); | |
| }, | |
| publish: function(obj, keypath, value) { | |
| obj.set(keypath, value); | |
| } | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment