nodejs Q.js promise

zyip發表於2015-02-27

 

var Q = require("q");

documentation for Q
https://github.com/kriskowal/q
https://github.com/kriskowal/q/wiki/API-Reference



Specification
https://promisesaplus.com


http://www.cnblogs.com/moye/p/promise_q_async.html


http://www.ituring.com.cn/article/54547

http://www.chenqing.org/2014/05/use-q-js-to-promise-in-node.html});



https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise




Q.fcall(delayOne).then(delayTwo).then(delayThree).then(delayFour).done();

//
denodeify
var fs_readFile = Q.denodeify(fs.readFile) 

var promise = fs_readFile('myfile.txt')

promise.then(console.log, console.error)


//none promise
  oauth2Client.getToken(code).then(function(){
            
        })
//promise
 var deferred= Q.defer();
        oauth2Client.getToken(code, deferred.makeNodeResolver());
        deferred.promise.then(function(tokens){

});

 



http://www.sitepoint.com/overview-javascript-promises/


http://www.sitepoint.com/deeper-dive-javascript-promises/




相關文章