module Athena::EventDispatcher::EventDispatcherInterface

Overview

Base type of an event dispatcher. Defines how dispatchers should be implemented.

Direct including types

Defined in:

event_dispatcher_interface.cr

Instance Method Summary

Instance Method Detail

abstract def add_listener(event : AED::Event.class, listener : AED::EventListenerType, priority : Int32) : Nil #

Adds the provided listener as a listener for event, optionally with the provided priority.


[View source]
abstract def dispatch(event : AED::Event) : Nil #

Dispatches event to all listeners registered on self that are listening on that event.

AED::EventListenerInterface's are executed based on the listener's priority; the higher the value the sooner it gets executed.


[View source]
abstract def has_listeners?(event : AED::Event.class | Nil) : Bool #

Returns true if there are any listeners listening on the provided event. If no event is provided, returns true if there are ANY listeners registered on self.


[View source]
abstract def listener_priority(event : AED::Event.class, listener : AED::EventListenerInterface.class) : Int32 | Nil #

Returns the listener priority for the provided event. Returns nil if no listeners are listening on the provided event or if listener isn't listening on event.


[View source]
abstract def listeners(event : AED::Event.class | Nil) : Array(AED::EventListener) #

Returns the listeners listening on the provided event. If no event is provided, returns all listeners.


[View source]
abstract def remove_listener(event : AED::Event.class, listener : AED::EventListenerInterface.class) : Nil #

Removes the provided event from the provided listener.


[View source]
abstract def remove_listener(event : AED::Event.class, listener : AED::EventListenerType) : Nil #

Removes the provided event from the provided listener.


[View source]