class EventEmitter::Base

Defined in:

event_emitter/base.cr

Instance Method Summary

Instance Method Detail

def all(once = false, &block : Any -> ) #

Listen to all events and run the specified block. This is the same as doing emitter.on(/.*/) { ... }


[View source]
def emit(event, arg = nil) #

Emit an event with the specified arg


[View source]
def on(event, *, once = false, &block : Any -> ) #

Listen for a particular event and fire the block every time that event is called. If #once is true the event will be removed after it is fired the first time.


[View source]
def once(event, &block : Any -> ) #

Sugar for on(event, once: true). Will fire the event once and then remove the listener.


[View source]
def remove_listener(id_or_event) #

Remove an event listener by id or event.


[View source]