Created
September 5, 2013 15:58
-
-
Save anonymous/6452151 to your computer and use it in GitHub Desktop.
query out of date error
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
var data = [ | |
{id: _.uniqueId(), name: 'some record 1'}, | |
{id: _.uniqueId(), name: 'some record 2'}, | |
{id: _.uniqueId(), name: 'some record 3'} | |
]; | |
var queriesDfd = new Deferred(); | |
var memQueryResults; | |
var AsyncStore = declare(MemoryStore, { | |
query: function () { | |
memQueryResults = MemoryStore.prototype.query.apply(this, arguments); | |
return queryResults(queriesDfd); | |
}, | |
}) | |
var memoryStore = new AsyncStore({data: data}); | |
var observableStore = observable(memoryStore); | |
var results = observableStore.query({}); | |
results.observe(function(){ | |
console.error("in observer"); | |
}, true); | |
// pretend a seperate poller script has retrieved some data and is notifying the store | |
observableStore.notify(data[0], data[0].id); | |
observableStore.notify(data[1], data[1].id); | |
observableStore.notify(data[2], data[2].id); | |
queriesDfd.resolve(memQueryResults); // when resolving this will cause the query out of date error | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment