Consider replacing our custom Promise.all with the one from ondras



6 years ago
6 years ago


(Reporter: gandalf, Unassigned)





6 years ago
When I added Promise.all, I didn't know that ondras wrote his:

It's mostly the same, but it collects results and has an errback.
The problem is that our Promise.all isn't really an 'all.'

ondras' .when rejects the promise the moment it first encounters an error.  Other promises passed to .when may finish after the error, and their result is irrelevant;  the promise has already been rejected.  By setting counter to Infinity in the errback, ondras makes sure the .when promise is never fulfilled.

We, OTOH, need a different behavior:  we need all promises to finish, and only after they do do we want to invoke the callback.  We don't care about the actual result (individual downloads may succeed or fail) as much as we do about making sure that the callback isn't invoked before all downloads finish.

To avoid confusion, we could rename our Promise.all to Promise.after or something like that.

Also, note that even in a scenario when all downloads fail we still want to invoke the callback and build the Locale object because there might have been inline resources added via ctx.addResource.

Comment 2

6 years ago
you're right. Let's stick to our solution. It's way better. The guy who wrote it must be a genius. 

Oh wait...
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.