Skip to content

Instantly share code, notes, and snippets.

@charlesjolley
Forked from ColinCampbell/observing.js
Created August 12, 2010 23:23
Show Gist options
  • Save charlesjolley/521957 to your computer and use it in GitHub Desktop.
Save charlesjolley/521957 to your computer and use it in GitHub Desktop.
var query = SC.Query.local(MyApp.Record);
var data = MyApp.store.find(query);
// old way
var f = function() {
if (data.get('status') & SC.Record.READY) {
data.removeObserver('status', this, f);
// ...
}
};
data.addObserver('status', this, f);
// proposed way
data.addFiniteObserver('status', this, function() {
if (data.get('status') & SC.Record.Ready) {
// ...
return YES;
}
});
@joshholt
Copy link

I like the proposed way... esp after writing tons of nodeJS code :0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment