Last active
August 2, 2024 13:35
-
-
Save wmakeev/4940da20c5a8c89f5c3f3b863fd5efb6 to your computer and use it in GitHub Desktop.
[Promise with resolvers] #promise #helper
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
export function getPromiseWithResolvers() { | |
let resolve; | |
let reject; | |
const promise = new Promise((resolve_, reject_) => { | |
resolve = resolve_; | |
reject = reject_; | |
}); | |
return { promise, resolve, reject }; | |
} |
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
export function getPromiseWithResolvers() { | |
let resolve: (value: unknown) => void; | |
let reject: (reason?: any) => void; | |
const promise = new Promise((resolve_, reject_) => { | |
resolve = resolve_; | |
reject = reject_; | |
}); | |
return { promise, resolve: resolve!, reject: reject! }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment