Skip to content

push


ts
import { push, type Push } from 'notivue'

Object containing methods to create, dismiss and destroy notifications.

Push Object Methods

MethodDescriptionParamReturn
successPush a success notificationstring | PushOptionsPushClearMethods
errorPush an error notificationstring | PushOptionsPushClearMethods
warningPush a warning notificationstring | PushOptionsPushClearMethods
infoPush an info notificationstring | PushOptionsPushClearMethods
promisePush a pending notificationstring | PushOptionsPushPromiseReturn
loadPush a pending notification (alias of promise)string | PushOptionsPushPromiseReturn
clearAllDismiss all notifications by playing clearAll animation.-void
destroyAllDismiss all notifications without playing any animation.-void

Interfaces

ts
type PushOptions = NotificationOptions &
  PushProps &
  PushSpecificOptions &
  PushCallbacks

interface NotificationOptions {
  title?: string
  message?: string
  duration?: number
  ariaLive?: 'polite' | 'assertive'
  ariaRole?: 'alert' | 'status'
}

interface PushProps {
  props?: Record<string, any>
}

interface PushSpecificOptions {
  skipQueue?: boolean
  ariaLiveOnly?: boolean
}

interface PushCallbacks {
  onAutoClear?: (item: NotivueItem) => void
  onManualClear?: (item: NotivueItem) => void
}

interface PushClearMethods {
  clear: () => void
  destroy: () => void
}

type PushPromiseReturn = PushClearMethods & {
  resolve: (options: string | PushOptions) => PushClearMethods
  reject: (options: string | PushOptions) => PushClearMethods
  //👇 Aliases of `resolve` and `reject` respectively
  success: (options: string | PushOptions) => PushClearMethods
  error: (options: string | PushOptions) => PushClearMethods
}