Skip to content

Instantly share code, notes, and snippets.

@mwheeler
Created March 12, 2015 05:39
Show Gist options
  • Save mwheeler/fc445c13f077bf208852 to your computer and use it in GitHub Desktop.
Save mwheeler/fc445c13f077bf208852 to your computer and use it in GitHub Desktop.
Promise.all example
var Promise = require('bluebird');
Promise.longStackTraces();
var A = new Promise(function(pass, fail)
{
console.log("A started");
setTimeout(function()
{
console.log("A finished");
pass();
}, 1000);
});
var B = new Promise(function(pass, fail)
{
console.log("B started");
setTimeout(function()
{
console.log("B finished");
pass();
}, 2000);
});
var C = console.log.bind(undefined, "YAY!");
Promise.all([A, B]).then(C, console.log.bind(undefined)).finally(console.log.bind(undefined, "\nTest Complete!"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment