tuil
ReferencePackages

@mwillbanks/tuil-events

Typed observable events and lifecycle signals for tuil applications.

View rawEdit

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-events

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

Documentation flow diagram. declare; subscribe; emit; route phases; observe; dispose; S0 leads to S1; S1 leads to S2
Documentation flow diagram. declare; subscribe; emit; route phases; observe; dispose; S0 leads to S1; S1 leads to S2

API

APISignatureDescription
defineEventsfunction defineEventsPublic function defineEvents.
eventfunction eventPublic function event.
EventBusclass EventBusPublic class EventBus.
EventDefinitioninterface EventDefinitionPublic interface EventDefinition.
EventDefinitionstype EventDefinitionsPublic type EventDefinitions.
EventEmitOptionsinterface EventEmitOptionsPublic interface EventEmitOptions.
EventMaptype EventMapPublic type EventMap.
EventPhasetype EventPhasePublic type EventPhase.
EventPrioritytype EventPriorityPublic type EventPriority.
EventSourceinterface EventSourcePublic interface EventSource.
EventSubscriptionOptionsinterface EventSubscriptionOptionsPublic interface EventSubscriptionOptions.
EventTargetinterface EventTargetPublic interface EventTarget.
ObservedEventinterface ObservedEventPublic interface ObservedEvent.
TuilEventinterface TuilEventPublic 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" });

On this page