You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could image that the array of arguments sent to event listeners is also returned:
const[foo,bar]=awaitemitter.once('done');
Re-using the once method for this would avoid introducing a new method name that could conflict with existing emitters.
Please don't focus on the listening use-case too much, it is just one example (and this is not stackoverflow). It's the code pattern that I would like to discuss.
I would love to get peoples' input on this. Is this something you would want to see too? Or not, and why not? Is there a more elegant solution you can think of? Thanks.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When in an async/await heavy project, EventEmitter can sometimes get a little in the way of a super smooth developer experience.
I would like to make this type of scenario simpler:
There are 2 problems here:
listening
event handler, an exception is thrown, it will be an unhandled one.Describe the solution you'd like
listening
is an event you only care about once, so it would be nice to haveemitter.once()
like behavior but for promises.I could image that the array of arguments sent to event listeners is also returned:
Re-using the
once
method for this would avoid introducing a new method name that could conflict with existing emitters.Please don't focus on the
listening
use-case too much, it is just one example (and this is not stackoverflow). It's the code pattern that I would like to discuss.I would love to get peoples' input on this. Is this something you would want to see too? Or not, and why not? Is there a more elegant solution you can think of? Thanks.
The text was updated successfully, but these errors were encountered: