Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Created September 29, 2010 21:02
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 unscriptable/603555 to your computer and use it in GitHub Desktop.
Save unscriptable/603555 to your computer and use it in GitHub Desktop.
// result sets (two identical queries)
var rs1, rs2;
//items to watch (two instances of same model data)
var item1, item2;
dojo.when(store.query({}), function (results) {
rs1 = results;
item1 = results[0];
// item1.get('prop') == 'foo'
});
dojo.when(store.query({}), function (results) {
rs2 = results;
item2 = results[0];
// item2.get('prop') == 'foo'
});
// later, in some app controller
item1.set('prop', 'bar'); // watchers of item1 get notified
store.put(rs1); // observers of rs1 and rs2 get notified
item2.get('prop'); // still 'foo', not 'bar', nobody got notified
rs2[0].get('prop') // 'bar' !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment