Created
August 18, 2011 15:34
-
-
Save dmachi/1154336 to your computer and use it in GitHub Desktop.
getting started with wrapping two stores with one
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 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