Created
October 13, 2017 06:48
-
-
Save Kinzi/7fc89bc94cea62f2b4b1e566023a290c to your computer and use it in GitHub Desktop.
Basic q promises nodejs
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
var q = require('q'); | |
// Single promise function | |
var promiseFunction = function(){ | |
var deferred = q.defer(); | |
deferred.resolve(); | |
return deferred.promise; | |
}; | |
// several promises | |
var promises = []; | |
promises.push( | |
promiseFunction() | |
//.then(funciton(res){ | |
// do something | |
//}) | |
); | |
q.all(promises) | |
.then(function(result){ | |
console.log(result); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment