Skip to content
docsv0.3.0

TuiEvent

One event published on a {@see \Milpa\Live\Contracts\Tui\TuiEventBusInterface}. `$type` is the dispatch key listeners subscribe by (e.g. `'job.started'`); event type naming is a bus-wide convention, not enforced by this class.

TuiEvent::__construct()

public function __construct(string $type, array $payload = [], ?string $source = null, float $time = 0):

Parameters

Parameters of __construct()
NameTypeDescription
$typestringThe event type, used for subscriber dispatch; MUST NOT be empty.
$payloadarray<string, mixed>Event-specific data.
$source(string | null)The component/subsystem that published this event, if identified.
$timefloatUnix timestamp (with microsecond precision) the event occurred at; `0.0` unless set via {@see now()}.

Throws

\InvalidArgumentException If `$type` is empty.

TuiEvent::now()

public static function now(string $type, array $payload = [], ?string $source = null): self

Builds an event timestamped with the current time ({@see microtime()}), for the common case of publishing an event as it happens.

Parameters

Parameters of now()
NameTypeDescription
$typestring
$payloadarray<string, mixed>
$source?string