Created
February 14, 2012 08:58
-
-
Save raroni/1824951 to your computer and use it in GitHub Desktop.
Wingman intelligent property changes
This file contains 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
# Wingman is a yet to be released coffeescript MVC framework. Throughout Wingman, WingmanObject is | |
# used for monitoring changes to a object in real time in various handy ways. | |
# The simplest use of #observe is like this: | |
o = new WingmanObject | |
o.set name: 'Ras' | |
o.observe 'name', -> alert 'cb fired!' | |
o.set name: 'Yogi' | |
# But what about more complex attributes like arrays? | |
o = new WingmanObject | |
o.set users: [] | |
o.observe 'users', -> alert 'cb fired!' | |
o.get('users').push 'Ras' | |
# The array is modified, but technically, it is still the same attribute on o. | |
# Should the callback fire? What would you expect? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment