jostylr / event-when

An event library that allows for firing events after a given set of events have fired.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

emitCache

jostylr opened this issue · comments

Thinking about adding an emitCache method. This would emit an event and then cache it so that any once methods defined later would be immediately called if it corresponded to this event. This would allow the emit to happen before the listener was installed. It is a bit like calling a function before it is defined.

I think this only makes sense for the once methods whose basic premise is a one-off event. The on handlers are more like watchers over a constant stream of events. They are in the present, while the once handlers can be past, present or future.

This is different than the cache method which is more for ensuring that an event is not emitted more than once, but it has no bearing on the once being called on a past event, I believe. These could be merged, but I think their purposes are different.