Created
December 23, 2010 14:23
-
-
Save dwt/753040 to your computer and use it in GitHub Desktop.
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
Arrayobservers = SC.Application.create({ | |
NAMESPACE: 'Arrayobservers', | |
VERSION: '0.1.0', | |
store: SC.Store.create().from(SC.Record.fixtures) | |
}); | |
Arrayobservers.objects = [SC.Object.create({foo: 1}), SC.Object.create({foo: 2})]; | |
Arrayobservers.objectsController = SC.ArrayController.create(); | |
Arrayobservers.contentNotifyingObjects = SC.Controller.create({ | |
objectsBinding: SC.Binding.oneWay('Arrayobservers.objectsController*content'), | |
// or perhaps this instead of the other one. | |
//objectsBinding: SC.Binding.oneWay('Arrayobservers*objectsController), | |
computedProperty: function() { | |
console.log('computedProperty', this.get('objects').getEach('foo').get('@sum')); | |
}.property('objects'), | |
computedPropertyObserver: function() { | |
this.get('computedProperty'); | |
}.observes('computedProperty') | |
}); | |
console.log('should now see computed property output twice'); | |
SC.RunLoop.begin(); | |
Arrayobservers.objectsController.set('content', Arrayobservers.objects); | |
SC.RunLoop.end(); | |
SC.RunLoop.begin(); | |
Arrayobservers.objects.get(1).set('foo', 5); // don't know what you are actually doing | |
SC.RunLoop.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
StoriesController = SC.ArrayController.create({
});
StoriesPointsController = SC.Controller.create({
storiesBinding: SC.Binding.oneWay('StoriesController*content'),
summedStoryPoints: function(){
// get the stuff and calculate
}.property('stories')
})