Cancelable promises

Kevin Smith zenparsing at gmail.com
Sun Mar 1 06:03:01 PST 2015


>
>
> That design seems far cleaner than adding functionality directly to
> promises, but can it be made JS-ergonomic?
>
>
The question we need to consider when it comes to a general design for
canceling async tasks is this:  how does one offer cancellation when
defining an async task using an async function?

    async function af() {
        // A bunch of awaits in here.
        // How can I allow the initiator to cancel?
    }

Adding a "cancel" method to (some) promises doesn't work for async
functions, but something like the cancellation token approach would.

So again the question is: can we come up with a cancellation-token-style
pattern which is JS-ergonomic?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150301/ea77d60f/attachment.html>


More information about the es-discuss mailing list