import { NotificationCenter } from '@stereograph/teiaviewer';
/**
* Simple example to send a notification to the viewer
* Status can be : 'info' | 'warning' | 'error' | 'success' | 'pending'
* If you don't pass an id, a random one will be generated
* and returned by the pushNotification method
* If you push a notification with the same id, it will replace the previous one with the new one.
* You can set the type you want. You can then filter by type in the NotificationCenterWidget
*/
NotificationCenter.instance.pushNotification(
{
type: 'your_type',
status: 'warning',
message: 'your_message',
title: 'your_title'
},
'id'
);
/**
* For example for a loading notification:
* This will update the notification, first with the new loading percentage,
* then with a new status and the final loading percentage.
*/
const id = NotificationCenter.instance.pushNotification({
type: 'viewer_loading',
status: 'pending',
message: '30%',
title: 'Chargement'
});
NotificationCenter.instance.pushNotification(
{
type: 'viewer_loading',
status: 'pending',
message: '70%',
title: 'Chargement'
},
id
);
NotificationCenter.instance.pushNotification(
{
type: 'viewer_loading',
status: 'success',
message: '100%',
title: 'Chargement'
},
id
);