Created
June 26, 2016 23:44
-
-
Save sahas-/dd28eeac7f79eb3096f6069cb5aa2b86 to your computer and use it in GitHub Desktop.
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
'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