Created
September 29, 2010 21:02
-
-
Save unscriptable/603555 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
// 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