Notification management functions and reactive state.
Creates and prepends a custom notification. Returns the new notification ID.
Removes all notifications from the center.
Alias for NotificationCenter.clear.
Adds an error notification (persistent by default). Returns the new notification ID.
Reactive boolean; true when at least one notification exists.
Adds an informational notification. Returns the new notification ID.
Reactive list of all notifications, ordered newest first.
Removes a notification by ID. No-op if the ID is not found.
Removes all notifications tagged with the given NotificationSource.
Removes resolved font-missed notifications based on the current missed-font set.
Removes notifications for which the predicate returns true.
Adds a success notification. Returns the new notification ID.
Reactive count of active notifications.
Adds a warning notification. Returns the new notification ID.
import { useNotificationCenter } from '@mlightcad/cad-viewer'
const { info, warning, error, success, notifications, unreadCount } = useNotificationCenter()
// Add different types of notifications
info('Information', 'This is an info message')
warning('Warning', 'This is a warning message')
error('Error', 'This is an error message')
success('Success', 'This is a success message')
// Add notification with actions
error('File Error', 'Failed to load file', {
actions: [
{ label: 'Retry', action: () => retryLoad(), primary: true },
{ label: 'Cancel', action: () => cancel() }
],
persistent: true
})
// Check notification count
console.log(`You have ${unreadCount.value} notifications`)
Composable that exposes the global notification center.
Provides a centralized notification system similar to Visual Studio Code. All returned state is reactive; multiple callers share the same underlying list.