Skip to content

Instantly share code, notes, and snippets.

@sahas-
Created June 26, 2016 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahas-/dd28eeac7f79eb3096f6069cb5aa2b86 to your computer and use it in GitHub Desktop.
Save sahas-/dd28eeac7f79eb3096f6069cb5aa2b86 to your computer and use it in GitHub Desktop.
'use strict';
var Q = require('q');
function test(){
var _test = Q.all([getPromise(1),getPromise(2),getPromise(3)]);
_test.spread(function(one,two,three){
console.log("one.."+one);
console.log("two.."+two);
console.log("three.."+three);
})
}
function getPromise(value){
var deferred = Q.defer();
setTimeout(function(value){
let test = Math.random();
console.log("returning "+ test);
deferred.resolve(test);
},2000);
return deferred.promise;
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment