Back to labs
Toast Deduper
A notification helper that groups repeated toast events into calmer nudges while preserving the latest important state.
Deduped notification queue
Repeated events update the existing toast instead of stacking identical messages, reducing noise during busy product flows.
Notes
- Duplicate events update one visible notification.
- Important status changes can still break through.
- Works well for async saves, syncs, and background jobs.
Code
A compact implementation sketch for the pattern behind this lab.
1type ToastEvent = {2 key: string;3 title: string;4 description?: string;5};6 7export function createToastDeduper() {8 const active = new Map<string, string>();9 10 return function notify(event: ToastEvent) {11 const toastId = active.get(event.key);12 13 if (toastId) {14 toast.message(event.title, {15 id: toastId,16 description: event.description,17 });18 return;19 }20 21 active.set(event.key, toast.message(event.title));22 };23}