class EventHandler::Wrapper(T)

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(handler : T, once : Bool = false, async : Bool = ::EventHandler.async?, at : Int32 = ::EventHandler.at_end, hash = nil) #

[View source]
def self.new(once = false, async = ::EventHandler.async?, at = ::EventHandler.at_end, hash = nil, &handler : T) #

[View source]

Instance Method Detail

def async? : Bool #

[View source]
def at : Int32 #

[View source]
def call(obj, async = nil) #

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.


[View source]
def handler : T #

[View source]
def handler_hash : UInt64 #

[View source]
def once? : Bool #

[View source]