emittery icon indicating copy to clipboard operation
emittery copied to clipboard

Allow event's listener to choose if events should be serial or non-serial

Open AuHau opened this issue 3 years ago • 1 comments

Currently, there is the emit()/emitSerial() that allows the emitter (emitting side) to specify if the event's processing should be awaited or not (eq. serial processing or not). I would like to argue that most of the time the emitter does not know and understand in what context are the events processed and if serial/parallel processing should be used, instead the listener is aware of this.

I would like to propose similar functionality on the listener side with functions on() and new onSerial().

I see it that when listener is registered with onSerial(), there would be a specific queue created for this listener which upon emit() would the emitted data be pushed to this queue.

A thing I am not so sure about is how it should behave for all the combinations of emit()/emitSerial() and on()/onSerial(), but that can be though out if this proposition would get traction.

Please let me know your thoughts, happy to write PR for this.

AuHau avatar Aug 18 '20 07:08 AuHau

You have a good point. However, I would like to resolve some fundamental issues in Emittery (#51) before getting to this.

sindresorhus avatar Dec 28 '20 17:12 sindresorhus