Skip to content

Instantly share code, notes, and snippets.

@wgottschalk-RMS
Last active July 11, 2016 18:48
Show Gist options
  • Save wgottschalk-RMS/82743447737de2149132efb727c2b8a0 to your computer and use it in GitHub Desktop.
Save wgottschalk-RMS/82743447737de2149132efb727c2b8a0 to your computer and use it in GitHub Desktop.
import co from 'co';
// with objects
co(function*() {
const {user1, user2, user3} = yield {
user1: user.findOneAsync({name: "Will"}),
user2: user.findOneAsync({name: "Adam"}),
user3: user.findOneAsync({name: "Ben"})
};
).catch(err => handleError(err))
// with arrays
co(function*() {
const [user1, user2, user3] = yield [
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