class
EventHandler::Wrapper(T)
- EventHandler::Wrapper(T)
- Reference
- Object
Overview
Generic class wrapping each installed handler.
Not generally used directly; implicitly created and returned by on(), and
sent as an argument to emitted AddHandlerEvent/RemoveHandlerEvent events.
Holds each handler's once, async, and at (initial insertion position in the handler list) settings. at is informational — mainly useful to check for 0 or -1, meaning insertion at the beginning or end of the list.
Defined in:
wrapper.crConstructors
- .new(handler : T, once : Bool = false, async : Bool = ::EventHandler.async?, at : Int32 = ::EventHandler.at_end, hash = nil)
- .new(once = false, async = ::EventHandler.async?, at = ::EventHandler.at_end, hash = nil, &handler : T)
Instance Method Summary
- #async? : Bool
- #at : Int32
-
#call(obj, async = nil)
Dispatches obj to the wrapped handler and returns obj.
- #handler : T
- #handler_hash : UInt64
- #once? : Bool
Constructor Detail
Instance Method Detail
Dispatches obj to the wrapped handler and returns obj.
Handlers are Proc(T, Nil), so their own return conveys nothing;
returning the dispatched event instead lets wait(type, handler)/
wait(type) { ... } yield it, matching the handler-less wait overloads.
The async branch also returns obj even though the handler runs in its
own fiber. _emit ignores this return value, so dispatch is unaffected.