Skip to content

Instantly share code, notes, and snippets.

@dmachi
Created August 18, 2011 15:34
Show Gist options
  • Save dmachi/1154336 to your computer and use it in GitHub Desktop.
Save dmachi/1154336 to your computer and use it in GitHub Desktop.
getting started with wrapping two stores with one
var store = function(substores,options){
return {
query: function(query){
var defs=[];
var results=[]
substores.forEach(function(sub,index){
defs.push(when(sub.query(query), function(resultSet){
results[index]=resultSet;
}));
}
return when(promise.all(defs), function(results){
var final=[];
results.forEach(r){
final = final.concat(r);
});
return final;
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment