Created
March 26, 2019 13:43
-
-
Save abhikhatri/04289ef0a7f16f3dcff27fb41d49ce45 to your computer and use it in GitHub Desktop.
Resolve promise from outside the scope
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
//Actual promise function that retuns a promise | |
function defer() { | |
var res, rej; | |
var promise = new Promise((resolve, reject) => { | |
res = resolve; | |
rej = reject; | |
}); | |
promise.resolve = res; | |
promise.reject = rej; | |
return promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment