Skip to content

Reusability

You might want to create reusable utilities to avoid passing always the same options or custom props. Here's an example:

Example

ts
import type { PushOptions } from 'notivue'

export interface MessageNotificationProps {
  name: string
  lastName?: string
  isMessageRequest?: boolean
}

export function pushMessageNotification({
  props = {} as MessageNotificationProps,
  ...options
}: PushOptions<MessageNotificationProps>) {
  push.info({
    title: 'Message Request', // Default options
    ...options, // Push options
    props: {
      isNewMessageRequest: true, // Default props
      ...props // Push props
    }
  })
}

pushMessageNotification({
  message: 'Maria sent you a message 3 hours ago.',
  duration: 9000,
  props: {
    name: 'Maria',
    lastName: 'Rossi'
  }
})