Bergi
Bergi
The `Promise` constructor takes a cancellation token argument (and lots of other API functions take one and pass it through to the promise constructor). But what exactly should one be...
This proposal allows promises to be cancelled through their associated token at _any time_ until it is settled. That means that when they are already resolved but still pending (i.e....
``` js new Promise(resolve => { const timer = setTimeout(resolve, t); return reason => clearTimeout(timer); }, token) ``` would be an extraordinarily convenient syntax to create cancellable promises. The returned...
The purpose of this method is > ``` > unsubscribe = token.???(onCancelled[, onUnsubscribe]) > ``` > > Subscribes the callback to be invoked on a cancellation request (or when the...
``` const {token, canel} = CancelToken.source(); const promise = …(token); // some promise that has the token associated const a = promise.trifurcate(…, …, r => { throw new Error(); });...
Most of the [existing implementations](/bergus/promise-cancellation/blob/master/prior_work.md#existing-implementations) do offer a `.cancel()` method on promises. It would be super slick if we could invoke this when assimilating such a cancellable thenable together with...
Related: https://github.com/zenparsing/es-cancel-token/issues/6 There are various ways one might want to compose cancellation tokens. One example can be found in the [demo implementation of Tasks](/bergus/promise-cancellation/blob/master/enhancements.md#demo-implementation), there are others. The main issue...
Should a promise be reported as unhandled when it had a `catch` handler installed but that was later cancelled? ``` js const {token, cancel} = CancelToken.source(); setTimeout(cancel, 500); const promise...
The method name `trifurcate` was a bit tongue-in-cheek. It might be technically accurate, but it's a horrible name. On purpose, because I'm bad at naming and not a native speaker....
Currently the proposal forces the token to be passed as the third argument to `then`, so that you have to explicitly pass `null`, `undefined` or some other non-callable value in...