API
Events
Subscribe to Toastflow lifecycle events for analytics, debugging, and UI reactions, including duplicates, updates, and timer resets.
Toastflow emits lightweight events through subscribeEvents.
Subscribe
const off = toast.subscribeEvents((event) => {
console.log(event.kind, event.id);
});
// call the returned function to stop listening
off();
Event Kinds
duplicate
ToastEventKind
show(...) found an existing match while preventDuplicates: true.timer-reset
ToastEventKind
A visible toast timer was reset (update, or resume with
pauseStrategy: "reset").update
ToastEventKind
update(id, options) succeeded.Each event is a { id, kind } object — id is the affected toast's ToastId.
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