when.any() & when.some() will be changing slightly

13 views
Skip to first unread message

Brian Cavalier

unread,
Oct 26, 2012, 12:41:52 PM10/26/12
to cuj...@googlegroups.com
for the better, we believe.  See this discussion about why the current behavior is a bit too non-deterministic-alicious, and what we think is a better approach.

Brian Cavalier

unread,
Oct 26, 2012, 2:28:52 PM10/26/12
to cuj...@googlegroups.com
Here is documentation that clarifies (I hope) how any() and some() will behave.  It uses a "competitive race" mental model, and makes them much more predictable.

Basically, as it was before, there was an extra (and confusing) level of nondeterminism.  So, say you had an input array of 10 promises and howMany == 5.  Let's say we somehow know apriori that 6 of the 10 will resolve and 4 of the 10 will reject.  Given that information, it seems like some() should always succeed simply because it can succeed.

In reality some() would either fail or succeed depending when it saw the very first rejection.  If you got lucky and saw 5 resolutions first, great, some() would succeed.  However, if you were unlucky and saw even 1 rejection before the 5th resolution (even though we know its possible to see all 5!), tough luck.  The same basic idea applies to any() as well.

Reply all
Reply to author
Forward
0 new messages