My proposal is that we add a way of removing a particular callback, or all 
callbacks, from a Promise. This is different to cancelling a Promise and would 
instead happen if you want the operation to continue but are no longer 
interested in running a function when the Promise is resolved or rejected.

This would be implemented in two ways. The first I believe to be most useful, 
and the second is a sort of “sub-proposal”, that I would be happy to leave out:

1. A new `Promise.prototype.clear()` method. This would remove all callbacks 
currently added to a Promise.
2. A `Promise.prototype.clear(promise)` method, which takes the Promise 
returned when `Promise.prototype.then()` or `Promise.prototype.catch()` was 
called. This would remove that specific callback leaving any others. I don’t 
know if another argument would make better sense here? Maybe an identifier to 
the one used in `clearInterval()`.

The use case that I see for this is for a Promise equivalent to 
`EventTarget.removeEventListener()`.

I look forward to hearing feedback on this. I am new to the process here and so 
am open to any advice and am happy to make changes on this if there is an 
approach that would be considered better practice.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to