ReferencePackages
@mwillbanks/tuil-events
Typed observable events and lifecycle signals for tuil applications.
Overview
Typed observable events and lifecycle signals for tuil applications.
@mwillbanks/tuil-events is independently installable and also participates in the
umbrella @mwillbanks/tuil runtime where applicable.
Installation
npm install @mwillbanks/tuil-eventsHow it operates
The typed event bus validates declared event names, schedules by priority, supports capture/target/bubble routing, redacts observed payloads, and keeps a bounded diagnostic history.
API
| API | Signature | Description |
|---|---|---|
defineEvents | function defineEvents | Public function defineEvents. |
event | function event | Public function event. |
EventBus | class EventBus | Public class EventBus. |
EventDefinition | interface EventDefinition | Public interface EventDefinition. |
EventDefinitions | type EventDefinitions | Public type EventDefinitions. |
EventEmitOptions | interface EventEmitOptions | Public interface EventEmitOptions. |
EventMap | type EventMap | Public type EventMap. |
EventPhase | type EventPhase | Public type EventPhase. |
EventPriority | type EventPriority | Public type EventPriority. |
EventSource | interface EventSource | Public interface EventSource. |
EventSubscriptionOptions | interface EventSubscriptionOptions | Public interface EventSubscriptionOptions. |
EventTarget | interface EventTarget | Public interface EventTarget. |
ObservedEvent | interface ObservedEvent | Public interface ObservedEvent. |
TuilEvent | interface TuilEvent | Public interface TuilEvent. |
Events and lifecycle
EventBus.emit() produces TuilEvent objects with source, target, metadata, priority, phase, cancellation, and propagation controls.
All subscriptions and registrations return a disposer or belong to an owning runtime that disposes them in reverse order.
Example
import { defineEvents, event, EventBus } from "@mwillbanks/tuil-events";
const events = new EventBus(defineEvents({ "build:done": event<{ id: string }>() }));
await events.emit("build:done", { id: "42" });