Created
September 21, 2011 18:33
-
-
Save skizzybiz/1232904 to your computer and use it in GitHub Desktop.
Observers for sub-properties don't work when using notifyPropertyChange
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
X.b.get('prop') // => 0 | |
X.b.setA(X.o) | |
X.b.get('prop') // => 0 | |
X.b.get('a').get('prop') // => 1 | |
X.b.notifyPropertyChange('prop') | |
X.b.get('prop') // => 1 |
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
X = { | |
a: SC.Object.create({ | |
prop: 1 | |
}), | |
b: SC.Object.create({ | |
a: function() { | |
return this._a; | |
}.property().cacheable(), | |
prop: function() { | |
a = this.get('a'); | |
if (SC.none(a)) return 0; | |
else return a.get('prop'); | |
}.property('*a.prop').cacheable(), | |
setA: function(a) { | |
this._a = a; this.notifyPropertyChange('a'); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment