W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

Re: Cancelable promises

From: Kevin Smith <zenparsing@gmail.com>
Date: Sun, 1 Mar 2015 09:03:01 -0500
Message-ID: <CA+mDt2w5QZgipogTeD749z1FEvaCaM796ys=aztB2XAFSPVHuQ@mail.gmail.com>
To: Ron Buckton <rbuckton@chronicles.org>, Anne van Kesteren <annevk@annevk.nl>, Domenic Denicola <d@domenic.me>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
> 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?
Received on Sunday, 1 March 2015 14:03:29 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC