Proposal: Allow Promise callbacks to be removed

T.J. Crowder tj.crowder at
Tue Apr 24 08:22:44 UTC 2018

On Mon, Apr 23, 2018 at 6:56 PM, Oliver Dunk
<oliver at> wrote:
> My proposal is that we add a way of removing a particular
> callback, or all callbacks, from a Promise.

As has been raised, this gets complicated quickly when chains come into it.
Also, what if the same function has been used in more than one place in the

If the simple flag folks have mentioned isn't general enough, I wonder if
you'd be better off with a cancelable *callback*:

function cancelableThen(f) {
    const wrapper = value => f(value);
    wrapper.cancel = () => {
        f = value => value;
    return wrapper;

// Using one:

function doSomething(value) {
    // Do something with the value
    return someResult;

const cb = cancelableThen(doSomething);

// Later, you decide you don't need to `doSomething` anymore
``` <>

Simple userland solution. Additional Promise semantics seem like overkill...

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list