Teek::UI::EventBus Class
In-process publish/subscribe for decoupled app events (:item_selected,
:theme_changed) - not Tk events, complementary to
Handle#on_click/Handle#on_key. Reach for this only when a direct
handle or a shared reactive Var would couple things that should
stay decoupled.
Owned by one Session (ui.on/ui.emit/ui.off) - two separate
Teek::UI.app instances in the same process never share a bus. Pure
Ruby, no Tk/interpreter involved, so it works before realize too.
Inherits: Object
Instance Methods ↑
emit(event, *args, **kwargs)
Emit a named event to every current subscriber, in subscription order.
Parameters
eventSymbolargsArray— forwarded to each subscriberkwargsHash— forwarded to each subscriber
Returns void
off(event, block)
Unsubscribe a specific listener.
Parameters
eventSymbolblockProc— the block#onreturned
Returns void
on(event, &block)
Subscribe to a named event.
Parameters
eventSymbol
Returns Proc — the block, to pass to a later #off
@yield the subscriber, called with whatever #emit was given