Last active
January 8, 2025 21:22
-
-
Save David200197/dad04cd2f0e73f94ee8ce536931fc7ef to your computer and use it in GitHub Desktop.
Promise Resolvers
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
| type Resolve<T> = (value: T) => void; | |
| type Reject = (reason?: any) => void; | |
| export const promiseResolver = <T>() => { | |
| let resolve: Resolve<T> = () => {}; | |
| let reject: Reject = () => {}; | |
| const promise = new Promise<T>((res, rej) => { | |
| resolve = res; | |
| reject = rej; | |
| }); | |
| return { resolve, reject, promise }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment