Skip to content

Instantly share code, notes, and snippets.

@wgottschalk-RMS
Created July 11, 2016 18:51
Show Gist options
  • Save wgottschalk-RMS/5f317fe884f2115ae9be65c8938acd9b to your computer and use it in GitHub Desktop.
Save wgottschalk-RMS/5f317fe884f2115ae9be65c8938acd9b to your computer and use it in GitHub Desktop.
// with the Bluebird library
import {props, all, coroutine} from 'bluebird';
// with objects
coroutine(function*() {
const {user1, user2, user3} = yield props({
user1: user.findOneAsync({name: "Will"}),
user2: user.findOneAsync({name: "Adam"}),
user3: user.findOneAsync({name: "Ben"})
});
)().catch(err => handleError(err))
// with arrays
coroutine(function*() {
const [user1, user2, user3] = yield all([
user.findOneAsync({name: "Will"}),
user.findOneAsync({name: "Adam"}),
user.findOneAsync({name: "Ben"})
]);
)().catch(err => handleError(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment