Skip to content
docsv0.3.0

TuiEventBusInterface

A synchronous publish/subscribe bus for {@see TuiEvent}s, decoupling event sources (e.g. {@see BackgroundJobManagerInterface} transitions) from whatever reacts to them (e.g. a job-monitor node renderer) without either depending on the other directly.

TuiEventBusInterface::subscribe()

abstract public function subscribe(string $eventType, callable $listener): void

Registers a listener for events of `$eventType`. The type `'*'` is a wildcard: implementations MUST invoke a `'*'` listener for every published event, regardless of its own type.

Parameters

Parameters of subscribe()
NameTypeDescription
$eventTypestring
$listenercallable(TuiEvent): void

TuiEventBusInterface::publish()

abstract public function publish(Milpa\Live\ValueObjects\Tui\TuiEvent $event): void

Publishes an event: appends it to {@see history()} and synchronously invokes every listener subscribed to its exact type plus every `'*'`-subscribed listener.

Parameters

Parameters of publish()
NameTypeDescription
$eventMilpa\Live\ValueObjects\Tui\TuiEvent

TuiEventBusInterface::history()

abstract public function history(): array

The full log of events published so far, in publish order.