useNotifications
Composable for managing notifications (flash messages) on frontend.
Types
ts
export function useNotifications(): UseNotificationsReturn
ts
export type Notification = {
type: NotificationType;
message: string;
id: number;
};
ts
export type NotificationOptions = {
/**
* @private
*/
type?: NotificationType;
timeout?: number;
persistent?: boolean;
};
ts
export type UseNotificationsReturn = {
/**
* List of active notifications
*/
notifications: ComputedRef<Notification[]>;
/**
* Removes a specific notification by its ID
*/
removeOne(id: number): void;
/**
* Resets the notification list - clear all notifications
*/
removeAll(): void;
/**
* Push an info notification to the current list
*/
pushInfo(message: string, options?: NotificationOptions): void;
/**
* Pushes a warning notification to the current list
*/
pushWarning(message: string, options?: NotificationOptions): void;
/**
* Pushes an error notification to the current list
*/
pushError(message: string, options?: NotificationOptions): void;
/**
* Pushes a success notification to the current list
*/
pushSuccess(message: string, options?: NotificationOptions): void;
};