You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
The cancel function passed to the executor of a CancelToken is the [[resolve]] function of its .promise.
This does let us do weird things like
const rejectedToken = new CancelToken(resolve => resolve(Promise.reject(…)));
const cancelledToken = new CancelToken(resolve => resolve(Promise.cancel(…)));
Are there any use cases for this? They don't make much sense to me.
The first one would probably only lead to a huge lot of unhandled rejections. Are token subscribers expected to deal with this?
The text was updated successfully, but these errors were encountered:
I see. In my approach I just used a token.subscribe(…) method instead of token.promise.then(…) where the callback is called directly with the cancellation reason - no promise resolution involved at all.
Of course that means that you'd have to do getEvent().then(cancel) instead of cancel(getEvent()), but I figured the latter is uncommon enough and doesn't provide any advantages.
The
cancel
function passed to the executor of aCancelToken
is the [[resolve]] function of its.promise
.This does let us do weird things like
Are there any use cases for this? They don't make much sense to me.
The first one would probably only lead to a huge lot of unhandled rejections. Are token subscribers expected to deal with this?
The text was updated successfully, but these errors were encountered: