Created
March 31, 2020 15:33
-
-
Save nmccready/0ae8dde3c631b2afddda619356925297 to your computer and use it in GitHub Desktop.
Promise.defer
This file contains hidden or 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
const defer = <T>() => { | |
let resolve, reject; | |
const promise = new Promise<T>((_resolve, _reject) => { | |
resolve = _resolve; | |
reject = _reject; | |
}); | |
return { | |
promise, | |
resolve, | |
reject, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment