MCPcopy
hub / github.com/simstudioai/sim / createToastFn

Function createToastFn

packages/emcn/src/components/toast/toast.tsx:125–134  ·  view source on GitHub ↗
(add: (input: ToastInput) => string)

Source from the content-addressed store, hash-verified

123let globalDismissAll: (() => void) | null = null
124
125function createToastFn(add: (input: ToastInput) => string): ToastFn {
126 const fn = ((input: ToastInput) => add(input)) as ToastFn
127 fn.success = (message, options) => add({ ...options, message, variant: 'success' })
128 fn.error = (message, options) => add({ ...options, message, variant: 'error' })
129 fn.warning = (message, options) => add({ ...options, message, variant: 'warning' })
130 fn.info = (message, options) => add({ ...options, message, variant: 'info' })
131 fn.dismiss = (id) => globalDismiss?.(id)
132 fn.dismissAll = () => globalDismissAll?.()
133 return fn
134}
135
136/**
137 * Imperative toast. Requires a mounted `<ToastProvider>`. A toast carrying an

Callers 2

toast.tsxFile · 0.85
ToastProviderFunction · 0.85

Calls 1

addFunction · 0.50

Tested by

no test coverage detected