class Athena::EventDispatcher::Spec::TracableEventDispatcher

Overview

Test implementation of AED::EventDispatcherInterface that keeps track of the events that were dispatched.

class MyEvent < AED::Event; end

class OtherEvent < AED::Event; end

dispatcher = AED::Spec::TracableEventDispatcher.new

dispatcher.dispatch MyEvent.new
dispatcher.dispatch OtherEvent.new

dispatcher.emitted_events # => [MyEvent, OtherEvent]

Defined in:

spec.cr

Instance Method Summary

Instance methods inherited from class Athena::EventDispatcher::EventDispatcher

dispatch(event : AED::Event) : AED::Event dispatch, has_listeners?(event_class : AED::Event.class) : Bool
has_listeners? : Bool
has_listeners?
, listener(callable : AED::Callable) : AED::Callable
listener(listener : T) : Nil forall T
listener(callable : AED::Callable, *, priority : Int32) : AED::Callable
listener(event_class : E.class, *, priority : Int32 = 0, name : String | Nil = nil, &block : E, AED::EventDispatcherInterface -> Nil) : AED::Callable forall E
listener
, listeners(for event_class : AED::Event.class) : Array(AED::Callable)
listeners : Hash(AED::Event.class, Array(AED::Callable))
listeners
, remove_listener(callable : AED::Callable) : Nil
remove_listener(listener : T) : Nil forall T
remove_listener

Instance methods inherited from module Athena::EventDispatcher::EventDispatcherInterface

dispatch(event : AED::Event) : AED::Event dispatch, has_listeners?(event_class : AED::Event.class) : Bool
has_listeners? : Bool
has_listeners?
, listener(callable : AED::Callable) : AED::Callable
listener(listener : T) : Nil forall T
listener(callable : AED::Callable, *, priority : Int32) : AED::Callable
listener(event_class : E.class, *, priority : Int32 = 0, name : String | Nil = nil, &block : E, AED::EventDispatcherInterface -> Nil) : AED::Callable forall E
listener
, listeners(for event_class : AED::Event.class) : Array(AED::Callable)
listeners : Hash(AED::Event.class, Array(AED::Callable))
listeners
, remove_listener(callable : AED::Callable) : Nil
remove_listener(listener : T) : Nil forall T
remove_listener

Instance Method Detail

def dispatch(event : AED::Event) : Nil #

:inherit:


[View source]
def emitted_events : Array(AED::Event.class) #

Returns an array of each AED::Event.class that was dispatched via this dispatcher.


[View source]