API
Events
Subscribe to toast lifecycle events for analytics, debugging, and UI reactions.
Toastflow emits lightweight events through subscribeEvents.
Subscribe
const off = toast.subscribeEvents((event) => {
console.log(event.kind, event.id);
});
off();
Event Kinds
| Kind | Emitted when |
|---|---|
duplicate | show(...) found an existing match while preventDuplicates: true |
timer-reset | Visible toast timer was reset (update or resume with pauseStrategy: "reset") |
update | update(id, options) succeeded |
Behavior Notes
Both events can fire in the same duplicate handling flow, depending on the action path.
Updating a queued toast emits
update but not timer-reset — no active timer exists yet.The event stream does not carry state snapshots. Use
subscribe(listener) for state.Typical Uses
- Trigger CSS bump or progress reset animations
- Analytics and telemetry for notification flows
- Debug queue and timer behavior during development