@dnakamashi/abortable-promise
v0.0.6
Published
Promises that can be aborted using AbortController
Downloads
2
Readme
abortable-promise
Promises that can be aborted using AbortController
const abortController = new AbortController()
const promise = new AbortablePromise(
(resolve, reject) => {
setTimeout(() => {
resolve('success')
}, 200)
setTimeout(() => {
reject('error')
}, 300)
},
{ signal: abortController.signal },
)
setTimeout(() => {
abortController.abort('aborted by the user')
}, 100)
promise
.then((result) => {
console.log(result)
})
.catch((error) => {
console.log(error)
})
It should log aborted by the user