File

notification/src/notification.service.ts

Description

Notification service allows consuming apps to create and manage notifications.

Features

  • Custom message and collapsible content
  • Notification levels (info, error, success, warning)
  • Custom icons (any icon from @talenra/icons is available)
  • Display a progress indicator (spinner) in place of the icon
  • Optional link with a callback function
  • Auto-dismiss functionality with customizable duration
Example :
private service: NotificationService = inject(NotificationService);
protected addNotification(): void {
  this.service.addNotification({ message: 'Hello world!' });
});

Import

Example :
import { NotificationService } from '@talenra/components/notification';

../../#/notification

Index

Methods

Methods

Public addNotification
addNotification(context: INotificationContext, removeCallback?: TRemoveNotificationCallback)

Creates and displays a new Notification. Context (message, type, icon, …) is provided in first parameter. The second parameter takes an optional callback that is invoked when the notification is about to be removed. Returns a unique identifier for the notification, which is typically stored in the consuming app (e.g. to remove the notification later).

Example :
const service: NotificationService = inject(NotificationService);
const identifier: string = service.addNotification(
  { message: 'Hello world!' },
  (identifier: string) => console.log(`Notification with identifier ${identifier} was removed.`)
);
Parameters :
Name Type Optional
context INotificationContext No
removeCallback TRemoveNotificationCallback Yes
Returns : string
Public removeAllNotifications
removeAllNotifications(options: IRemoveNotificationOptions)

Removes all notifications. By default the removal is animated. Use the animated option to bypass the exit animation and remove all notifications immediately.

Example :
const service: NotificationService = inject(NotificationService);
service.removeAllNotifications();
Parameters :
Name Type Optional Default value
options IRemoveNotificationOptions No { animated: true }
Returns : void
Public removeNotification
removeNotification(identifier: string, options: IRemoveNotificationOptions)

Removes the notification with the identifier given. By default, the removal is animated. Use the animated option to bypass the exit animation and remove the notification immediately.

Example :
const service: NotificationService = inject(NotificationService);
service.removeNotification(identifier);
Parameters :
Name Type Optional Default value
identifier string No
options IRemoveNotificationOptions No { animated: true }
Returns : void

results matching ""

    No results matching ""