Skip to content

Instantly share code, notes, and snippets.

@abhikhatri
Created March 26, 2019 13:43
Show Gist options
  • Save abhikhatri/04289ef0a7f16f3dcff27fb41d49ce45 to your computer and use it in GitHub Desktop.
Save abhikhatri/04289ef0a7f16f3dcff27fb41d49ce45 to your computer and use it in GitHub Desktop.
Resolve promise from outside the scope
//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