Appearance
useNotifications ​
Definition ​
Composable for managing notifications (flash messages) on frontend.
Basic usage ​
ts
const {
notifications,
removeOne,
removeAll,
pushInfo,
pushWarning,
pushError,
pushSuccess
} = useNotifications();
Signature ​
ts
export function useNotifications(): UseNotificationsReturn
Return type ​
See UseNotificationsReturn
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;
};
Properties ​
Name | Type | Description |
---|---|---|
notifications | ComputedRef<Array<Notification>> | List of active notifications |
Methods ​
Name | Type | Description |
---|---|---|
removeOne | void | Removes a specific notification by its ID |
removeAll | void | Resets the notification list - clear all notifications |
pushInfo | void | Push an info notification to the current list |
pushWarning | void | Pushes a warning notification to the current list |
pushError | void | Pushes an error notification to the current list |
pushSuccess | void | Pushes a success notification to the current list |