Created
March 2, 2022 22:19
-
-
Save AirStair/302fd600a052b5dbfe76b7b07d1f30e1 to your computer and use it in GitHub Desktop.
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
function promiseAbortController (asyncFunction) { | |
let controller = {} | |
controller.signal = new Promise((resolve, reject) => { | |
controller.abort = reject | |
asyncFunction().then(resolve) | |
}) | |
return controller | |
} | |
const { signal, abort } = promiseAbortController(async () => {}) | |
abort() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment