Created
May 4, 2012 08:19
-
-
Save polaris/2593239 to your computer and use it in GitHub Desktop.
SC Observer
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
UJAM.Node = SC.Object.extend({ | |
parentNode: null, | |
childNodes: [], | |
childsDidChange: function () { | |
alert('child nodes changed'); | |
}.observes('childNodes'), | |
addChild: function (node) { | |
this.childNodes.push(node); | |
this.notifyPropertyChange('childNodes'); | |
} | |
}); | |
UJAM.root = UJAM.Node.create({}); | |
UJAM.NodeObserver = SC.Object.extend({ | |
childsDidChange: function () { | |
alert('child nodes changed'); | |
}.observes('UJAM.root.childNodes'), | |
}); | |
UJAM.obs = UJAM.NodeObserver({}); | |
UJAM.root.addChild(UJAM.Node.create({})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment