Skip to content

Instantly share code, notes, and snippets.

@raroni
Created February 14, 2012 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raroni/1824951 to your computer and use it in GitHub Desktop.
Save raroni/1824951 to your computer and use it in GitHub Desktop.
Wingman intelligent property changes
# 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