Proposal: Allow Promise callbacks to be removed
Andrea Giammarchi
andrea.giammarchi at gmail.com
Tue Apr 24 07:57:02 UTC 2018
The `isStillValid` is limited in possibilities. I think listeners open new
possibilities, specially for very complex operations.
I see a simple scenario like the following one:
- user asks for a very expensive task clicking section A
- while it's waiting for it, user changes idea clicking section B
- both section A and section B needs that very expensive async call
- drop "going to section A" info and put "go to section B" to that very
same promise
- whenever resolved, do that action
A caching mechanism to trigger only once such expensive operation would
also work, yet it's not possible to drop "go into A" and put "go into B"
My PoC also is per promise, so if you use `.then()` over the passed along
promise, you can add your own listeners in there too, without affecting the
initial one (and vice versa)
On Mon, Apr 23, 2018 at 11:07 PM, Alex Vincent <ajvincent at gmail.com> wrote:
>
> 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.
>>
>
> Devil's advocate from the peanut gallery: what's so hard about adding:
>
> ```javascript
> if (!isStillValid) return;
> ```
> --
> "The first step in confirming there is a bug in someone else's work is
> confirming there are no bugs in your own."
> -- Alexander J. Vincent, June 30, 2001
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180424/deb8f0d5/attachment.html>
More information about the es-discuss
mailing list