Your oboe problem is based on the fact that there are Joson races in the stream, so we never know in advance how many promises there are, so we cannot assign responsibility to Promise.all in Promise.all . We can βpromiseβ the oboe to be able to return promises in our methods.
Typically, I would use RxJS to automatically create a stream from an event. The emitter and RxJS method can already return promises and then aggregate it. Nevertheless, since I do not want to use a library of third-party developers, and it has less educational value, let it implement it:
function addMap(oboe) { oboe.map = function(selector, mapper){ var promises = []; return new Promise(function(resolve, reject){
What would we do:
var o = oboe("foo"); addMap(o); o.map("items.*", item => downloadItem(item)).then(result => {
Your setTimeout question is very contrived. The vast majority of people do not write code that looks like this in practice - in practice, adding an error handler asynchronously is a rather rare case when you are not working with an API that forces you to do this (for example, the Oboe.js example).
Which is really strange: modern browsers behave differently
This is because Firefox uses the GC to detect raw failures and the Chrome timer. This implementation detail - the only guarantee you will receive is that errors will not be logged if they are attached to a microtask (synchronously or then , which runs on the same move).
source share