Last active
April 16, 2018 06:52
-
-
Save craigp/10dd66cca5dd62c1a53d 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
var Q = require('q'); | |
function test2(stuff) { | |
return Q.promise(function(resolve, reject, notify) { | |
resolve("fml"); | |
}); | |
} | |
function test1(what) { | |
return Q.promise(function(resolve, reject, notify) { | |
Q(what) | |
.then(function(_what) { | |
console.log(_what); | |
if (_what === "what") { | |
console.log("resolving"); | |
reject("fuck"); | |
} else { | |
return test2(_what); | |
} | |
}) | |
.then(function(fml) { | |
console.log("WHY AM I HERE?", fml); | |
resolve(fml); | |
}) | |
.catch(function(err) { | |
console.log("err", err); | |
}); | |
}); | |
} | |
test1("what") | |
.then(function(result) { | |
console.log(result); | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment