Skip to content

Instantly share code, notes, and snippets.

/gist:6452151

Created Sep 5, 2013
Embed
What would you like to do?
query out of date error
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