Created
February 26, 2014 17:57
-
-
Save ayapi/9234760 to your computer and use it in GitHub Desktop.
medikoo/deferredでresolve/rejectどっちが呼ばれても同じ処理をしたぃ時にっかぅ`.cb()` チェインもできるし、ぃーかんじ↑
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 deferred = require('deferred'); | |
var _ = require('lodash'); | |
var def = deferred(); | |
_.delay(function(){ | |
def.reject(new Error('error')); | |
//def.resolve('success'); | |
}, 1000); | |
def.promise.cb(function(result){ | |
console.log(1); | |
return result; | |
}).cb(function(result){ | |
console.log(2); | |
console.log(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment