View as Markdown

API reference: @salmonui/notifications/toast

ToastQueueinterface

import type { ToastQueue } from '@salmonui/notifications/toast';
interface ToastQueue {
    add(options: ToastOptions): string;
    update(id: string, options: ToastOptions): void;
    dismiss(id?: string, reason?: ToastCloseReason): void;
    pause(): void;
    resume(): void;
    setMax(max: number): void;
    subscribe(listener: () => void): () => void;
    getSnapshot(): ToastQueueSnapshot;
}

A toast queue: create one with createToastQueue() or let Toaster create it.

ToastQueue members (8)
NameSignatureDescription
addadd(options: ToastOptions): string;

Adds a toast and returns its id. A no-op returning '' on the server.

updateupdate(id: string, options: ToastOptions): void;

Merges options into a toast; a new duration restarts its timer.

dismissdismiss(id?: string, reason?: ToastCloseReason): void;

Closes a toast, or every toast without an id (waiting toasts leave silently). reason defaults to 'programmatic'.

pausepause(): void;

Pauses every timer; calls nest, each pause() needs a resume().

resumeresume(): void;

Undoes one pause(); timers continue with their remaining time.

setMaxsetMax(max: number): void;

Sets the number of visible toasts.

subscribesubscribe(listener: () => void): () => void;
getSnapshotgetSnapshot(): ToastQueueSnapshot;