Closed domenic closed 8 years ago
Can you elaborate on the semantic/meaning/purpose of this method, to help contextualize the naming?
Which slide in particular?
I guess my attempts at deep-linking didn't work... slides 20 through 22.
It seems like either Promise.race
or Array#some
is the analog here - i think either "race" (for symmetry with Promise) or "some" (for conceptual symmetry with Array.prototype) is probably the best approach? I think "any" might be a better name, but then I think that's a better name for "Array#some" also :-p
The discussions we had for promise are coming back to me now. I think they went something like this...
Now, how do we apply this to cancel tokens? Hmm.
I guess this has me leaning toward either "any" or "race".
Ah, so you're saying that Promise.any
is another possible static method that could exist in the future, that would reject only if all of the promises rejected, and would fulfill if any of them resolved? That makes tons of sense to me.
The counterpart to race
could be "together", or "complete", or "finished", or "fufilled", or "settled" - but yeah it's a tricky one.
Given that promises have three states (pending, resolved, rejected), and "race" says "the first one that's not pending wins" - altho cancel tokens have two (pending, cancelled) - "race" might apply best.
Ah, so you're saying that Promise.any is another possible static method that could exist in the future, that would reject only if all of the promises rejected, and would fulfill if any of them resolved? That makes tons of sense to me.
Yeah. I really want it; the problem is designing the "AggregateError" type that you use to signal error if they all reject. I thought that would be a Bikeshed factory. But then again, cancelable promises is going OK, so maybe I should try that :).
Seems easier than coming up with a way to do Promise.settle
and have a way to distinguish rejection from resolution :-p i say go for it! :-D
race
and any
sound equally good and race
is terminology we're using for something similar anyway - so +1 on that.
@domenic Don't forget to rename it in Cancel Tokens.md as well
Possible names: