Created
June 25, 2015 20:00
-
-
Save ghiden/d5f12108d9e2e7503bc5 to your computer and use it in GitHub Desktop.
Q delay behavior
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'); | |
function test() { | |
var d = Q.defer(); | |
setTimeout(function() { | |
d.reject(new Error('failed')); | |
}, 500); | |
return d.promise; | |
} | |
var result = test().delay(1000); | |
console.log(result); | |
setTimeout(function() { | |
console.log(result); | |
}, 800); | |
setTimeout(function() { | |
console.log(result); | |
}, 1500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment