This is not your problem to fix.
Just use promises the way they were intended. If the end user doesn't want to handle all rejections then THEY have to add an unhandledRejection handler. Otherwise they will need to add catches.
If your errors truly aren't breaking then you shouldn't be rejectin...
@Trasiva same deal, you cannot compare her actions on election night with some other stuff that happened. election night she is of course going to be up till the end and active
@BenjaminGruenbaum you mean there are cases where promises get rejected that shouldn't kill the process? That's kinda out of our hands. If the implementation says that's what happens then that is what happens.
@david I mean, there are times where promises are rejected but you'd want to handle it later and later never comes. Imagine adding a .loaded promise to an Image tag, and the image starts downloading when you construct it and not when you access the promise.
@Trasiva yea, again, not defending her, but using that tidbit of information to 'nail her' is weak af. there is so much better ammo you could use and has been used.
@Trasiva yea, and given everything that happened over the past year, I think it was a weak remark. an attempt to attack character (which I am not saying is wrong, she's terrible) but you choose a really crappy example to use.
I have spent many hours debating these semantics and arguing for a not silent default (as well as writing the PR that adds one). There are legitimate cases for this.
@david yes they will... they can still attach a catch handler just fine and get the exception. Promises fork, you can handle the rejection multiple times.
var p = Promise.reject();
p.catch(() => console.log("I run")); // need at least one
p.catch(() => console.log("me too"));
p.catch(() => console.log("me three"));
@BenjaminGruenbaum Hmm, okay. It still seems like a pretty odd thing to do. Basically just abusing the way unhandledRejection detects unhandled rejections
@ssube no, post workout, post shower - put on undies, socks, shoes... realized I didn't have my jeans on. tried to push my shoes into my jean legs. didn't work. had to take of my shoes
@david why? Bluebird has an explicit .suppressUnhandledRejection btw. I think an empty catch is pretty explicit. It conveys exactly that we're listening for rejections for this promise but ignoring the result.
A rejection is only unhandled if no one listens to it.
@BenjaminGruenbaum I just like consistency. If someone's code is giving me a promise i'd rather it was a native promise, and if I don't handle the rejection then I'd expect it to throw an unhandledRejection error. That's what the error is for and it would be fucking weird to debug if it didn't happen
@BenjaminGruenbaum how do you expect the code to know whether the end user wants the image to load or not? Maybe it's really important and the user actually really needed to add a catch. This way you're completely suppressing the error :S
@david the reason Node has unhandledRejection is because I specced it and got a friend and former RO to write that code. The reason it warns is because I wrote that behavior.
@BenjaminGruenbaum I don't care if you specced it or not. If the end user doesn't care about rejection then it's THEIR responsibility to add the empty catch. You don't get to dictate their requirements just because you think they're not interested in the rejection
@david no, there really aren't. I still haven't heard how you'd solve buffering in async iterators, or how you'd write Image. There are cases where it is necessary.
@david that's not an answer, play the role of the implementor of an Image exposing library (like WHATWG) - what would you do in that case? What about an async iterator that needs to buffer?
@david load an image (either when I first assign to its .source property or pass it to the constructor and have a .loaded property that returns a promise that resolves when it loads and rejects when it fails. It also needs properties like .width etc.
> Internally, Emacs has a model of what each frame used to look like, before the last invocation of redisplay. This model is one of redisplay’s inputs. Another input is the current contents of each Emacs buffer. Redisplay essentially diffs the last-known display configuration and what it’s supposed to be displaying right now, then emits a minimal set of terminal control codes needed to change the last-known state to the current-good state.
Check out the node issue, there are lots of examples - you can't really solve those like you couldn't really solve this one other than "I'd change the whole existing object API"
As for "an async iterator that caches the next value" surely the iterator itself should be handling rejections and retrying? Why expose that to the end user?
@Loktar Right? I mean, it doesn't substitute basic firearm safety, but it's still a nice supplementary. Side note, I'm looking at getting a 9mm here soon, probably next month.
Wait, what do you mean by 'caches the next value'? Do you only trigger the next action once the previous one has been accessed? Are these promises not all running in parallel?
@david no, it's an async iterator, for the consumer the promises don't run in parallel unless he asks for several values - see docs.google.com/presentation/d/…
hey, does anyone here know a bit of Web Audio API ?
When I create an Audio(), it contains a currentTime with the current time of the playing audio.
I found that the context of Web Audio API has a similar currentTime, but it's useless since it's relative to when the context is created. Is there anyway to get the currentTime relative to a source buffer ?
@BenjaminGruenbaum Okay, I've viewed your slides and read through github.com/tc39/proposal-async-iteration which seems to be the proposal for it so I think I have a basic grasp of async iterators.
Your question was how I would make an async iterator that eagerly cached a single value ahead, even if the user had not explicitly called .next() yet?
and how I would handle having that internal promise be rejected
Actually that can't be what you wanted because it's trivial as you haven't yet returned a promise for the value you're caching... you'd return it on the next call to next()
@KevinB yeah, I already did that. Searching Stackoverflow has an unaccepted answer with ugly Date(), counting milliseconds and timeout is also suggested elsewhere