> Cool, I'm aware that cancellable promises have been explored in depth.
I'd prefer to keep this thread focused on cancellation tokens though, and
avoid comparisons.

Cool, re-reading the discussion you asked for this in the first message - I
apologize for missing it.

I think using promises as tokens would be problematic. It would have
several issues:

 - You'd want to be able to  `cancel` things like Promise.all and
`Promise.race` - with a separate type you can use "the last argument", with
a promise you would not be able.
 - The names would get confusing for the users. Like Domenic said -
`whenCancelled` sounds a lot clearer. Sort of like the function vs. object
discussion on es-observable.
 - You get some weird scenarios like cancelling a cancellation.
 - You'd probably need to add properties anyway so that tokens can be
aggregated.

I do definitely see the use for `whenCancelled` and have used its
equivalent myself in C#.


It's also important to keep in mind that promises can be subclassed so it's
fine to add properties to them if used for a specific purpose like
cancellation.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to