module EventHandler
Defined in:
event.crevent_handler.cr:1
event_handler.cr:10
events.cr
macros.cr
wrapper.cr
Constant Summary
-
VERSION =
"0.5.0"
Class Method Summary
-
.async=(async)
Asynchronous execution flag.
-
.async?
Asynchronous execution flag.
Instance Method Summary
-
#emit(type : EventHandler::ExceptionEvent.class, obj : EventHandler::Event)
Emits event type with provided parameters.
-
#emit(type : EventHandler::AnyEvent.class, obj : EventHandler::Event)
Emits event type with provided parameters.
-
#emit(type : EventHandler::AddHandlerEvent.class, obj : EventHandler::Event)
Emits event type with provided parameters.
-
#emit(type : EventHandler::RemoveHandlerEvent.class, obj : EventHandler::Event)
Emits event type with provided parameters.
-
#emit(type : EventHandler::ExceptionEvent.class, *args)
Emits event type with provided parameters.
-
#emit(type : EventHandler::AnyEvent.class, *args)
Emits event type with provided parameters.
-
#emit(type : EventHandler::AddHandlerEvent.class, *args)
Emits event type with provided parameters.
-
#emit(type : EventHandler::RemoveHandlerEvent.class, *args)
Emits event type with provided parameters.
-
#handlers(type : EventHandler::ExceptionEvent.class)
Returns list of handlers for event type.
-
#handlers(type : EventHandler::AnyEvent.class)
Returns list of handlers for event type.
-
#handlers(type : EventHandler::AddHandlerEvent.class)
Returns list of handlers for event type.
-
#handlers(type : EventHandler::RemoveHandlerEvent.class)
Returns list of handlers for event type.
-
#off(type : EventHandler::ExceptionEvent.class, handler : Proc(EventHandler::ExceptionEvent, Bool))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::ExceptionEvent.class, hash : UInt64)
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::ExceptionEvent.class, handler : EventHandler::Wrapper(Proc(EventHandler::Event, Bool)))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AnyEvent.class, handler : Proc(EventHandler::AnyEvent, Bool))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AnyEvent.class, hash : UInt64)
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AnyEvent.class, handler : EventHandler::Wrapper(Proc(EventHandler::Event, Bool)))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AddHandlerEvent.class, handler : Proc(EventHandler::AddHandlerEvent, Bool))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AddHandlerEvent.class, hash : UInt64)
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::AddHandlerEvent.class, handler : EventHandler::Wrapper(Proc(EventHandler::Event, Bool)))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::RemoveHandlerEvent.class, handler : Proc(EventHandler::RemoveHandlerEvent, Bool))
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::RemoveHandlerEvent.class, hash : UInt64)
Removes handler from list of handlers for event type.
-
#off(type : EventHandler::RemoveHandlerEvent.class, handler : EventHandler::Wrapper(Proc(EventHandler::Event, Bool)))
Removes handler from list of handlers for event type.
-
#on(type : EventHandler::ExceptionEvent.class, handler : Proc(EventHandler::ExceptionEvent, Bool), once = false, async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::ExceptionEvent.class, once = false, async = ::EventHandler.async?, at = -1, &handler : EventHandler::ExceptionEvent -> Bool)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::AnyEvent.class, handler : Proc(EventHandler::AnyEvent, Bool), once = false, async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::AnyEvent.class, once = false, async = ::EventHandler.async?, at = -1, &handler : EventHandler::AnyEvent -> Bool)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::AddHandlerEvent.class, handler : Proc(EventHandler::AddHandlerEvent, Bool), once = false, async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::AddHandlerEvent.class, once = false, async = ::EventHandler.async?, at = -1, &handler : EventHandler::AddHandlerEvent -> Bool)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::RemoveHandlerEvent.class, handler : Proc(EventHandler::RemoveHandlerEvent, Bool), once = false, async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#on(type : EventHandler::RemoveHandlerEvent.class, once = false, async = ::EventHandler.async?, at = -1, &handler : EventHandler::RemoveHandlerEvent -> Bool)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::ExceptionEvent.class, handler : Proc(EventHandler::ExceptionEvent, Bool), async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::ExceptionEvent.class, async = ::EventHandler.async?, at = -1, &handler : EventHandler::ExceptionEvent -> Bool)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::AnyEvent.class, handler : Proc(EventHandler::AnyEvent, Bool), async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::AnyEvent.class, async = ::EventHandler.async?, at = -1, &handler : EventHandler::AnyEvent -> Bool)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::AddHandlerEvent.class, handler : Proc(EventHandler::AddHandlerEvent, Bool), async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::AddHandlerEvent.class, async = ::EventHandler.async?, at = -1, &handler : EventHandler::AddHandlerEvent -> Bool)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::RemoveHandlerEvent.class, handler : Proc(EventHandler::RemoveHandlerEvent, Bool), async = ::EventHandler.async?, at = -1)
Adds handler to list of handlers for event type.
-
#once(type : EventHandler::RemoveHandlerEvent.class, async = ::EventHandler.async?, at = -1, &handler : EventHandler::RemoveHandlerEvent -> Bool)
Adds handler to list of handlers for event type.
-
#remove_all_handlers(type : EventHandler::ExceptionEvent.class)
Clears list of handlers for event type.
-
#remove_all_handlers(type : EventHandler::AnyEvent.class)
Clears list of handlers for event type.
-
#remove_all_handlers(type : EventHandler::AddHandlerEvent.class)
Clears list of handlers for event type.
-
#remove_all_handlers(type : EventHandler::RemoveHandlerEvent.class)
Clears list of handlers for event type.
Class Method Detail
Asynchronous execution flag. By default, asynchronous execution of handlers is disabled.
To enable it, set this value to true:
EventHandler.async? # => false
EventHandler.async = true
Note that this setting only affects default value.
The value can be overriden using the argument async by every handler which subscribes to an event.
Asynchronous execution flag. By default, asynchronous execution of handlers is disabled.
To enable it, set this value to true:
EventHandler.async? # => false
EventHandler.async = true
Note that this setting only affects default value.
The value can be overriden using the argument async by every handler which subscribes to an event.
Instance Method Detail
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Emits event type with provided parameters.
If all handlers run synchronously, returns Bool. If any handler runs asynchronously, returns nil.
Returns list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Removes handler from list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Adds handler to list of handlers for event type. After it triggers once, it is automatically removed.
The same behavior is obtained using #on
and providing argument once.
Clears list of handlers for event type.
The removal of handlers is immediate and no RemoveHandlerEvent
events are emitted.
Clears list of handlers for event type.
The removal of handlers is immediate and no RemoveHandlerEvent
events are emitted.
Clears list of handlers for event type.
The removal of handlers is immediate and no RemoveHandlerEvent
events are emitted.
Clears list of handlers for event type.
The removal of handlers is immediate and no RemoveHandlerEvent
events are emitted.