ActionChannel
A typed multi-subscriber channel for one action of a trigger. Returned by
trigger.action(name) (cached per (trigger, name)). Replaces the v0.9
pattern of hand-rolled Set<callback> + for-of fan-out wired through
runtime.registerAction.
Import
Section titled “Import”Signature
Section titled “Signature”Channel subscribers and any runtime.registerAction(...) handler for the same key both fire on every action emit — the channel is additive, not a replacement.
Caching
Section titled “Caching”The channel is cached per (trigger, name). Repeat trigger.action(name) calls return the same channel object.
This means you can use t.action('X') as a stable reference for hooks and effects without memoising.
Coexistence with runtime.registerAction
Section titled “Coexistence with runtime.registerAction”The runtime.registerAction path remains last-write-wins (a single slot per action — newer writes overwrite older). Channel subscribers run additively in addition to that slot’s handler. This means:
- v0.10 React/Solid/Vue
useActioninternally uses the channel path → multiple components mounting the sameuseAction(trigger, 'name', fn)now all run on each emit. (This is the one semantic change in v0.10 — see the migration guide.) - Adapters that need exclusive ownership can keep using
runtime.registerAction(...). The two paths don’t interfere.
React example
Section titled “React example”useAction is a thin wrapper over trigger.action('showToast').subscribe(...) — every component that mounts it gets called on every emit.
ESLint rule
Section titled “ESLint rule”The prefer-action-channel rule (enabled as warn in the strict preset) flags the v0.9 hand-rolled Set + for-of fan-out pattern and suggests the channel API.