Skip to content

@xtandard/lib/sonner

Toast helpers that stream iterables/generators through Sonner (peers sonner, react).

import { … } from "@xtandard/lib/sonner";
Name Summary
toastStream Like toast.promise but for iterables/generators/streams.
toastStreamAsync Non-blocking version that returns immediately, in the spirit of toast.promise(...).unwrap(). Returns { id, unwrap }: the toast id, and an unwrap() method to await the result later. If you never call unwrap(), a failed stream only shows the error toast (no unhandled rejection). Accepts either an instance or a factory function.
Name Summary
LoadingExtendedResult Extended loading result with toast options
StreamExtendedResult A toast message plus full Sonner toast options.
Name Summary
DelayConfig Granular delay configuration
ErrorPartialData Partial data available when an error occurs
LoadingExtendedResultT Extended loading result, or a (sync or async) callback returning one
LoadingResultT Loading result - no data, just static or callback
StreamErrorResultT Error result - callback receives error first, then partial data
StreamExtendedErrorResultT Extended error result with toast options
StreamExtendedResultT Extended result includes full toast options
StreamExternalToast Sonner’s ExternalToast options minus description (the streamed message replaces it).
StreamingData Streaming progress data passed to callbacks
StreamResult Result of consuming a stream
StreamResultT Result can be string, ReactNode, or callback returning either (sync or async)
SuccessData Success data passed to callbacks - includes return value if generator has one
ToastStreamData Options matching Sonner’s PromiseData pattern
ToastStreamReturn What toastStreamAsync returns: the toast id plus unwrap() for the result.