import INotificationService , { INotification , INotificationHandler , NotificationType } from "./INotificationService" ; class NotificationServiceImpl implements INotificationService { private notificationHandlers : INotificationHandler [ ] = [ ] ; public deregisterNotificationHandler ( handler ) { const index = this . notificationHandlers . indexOf ( handler , 0 ) ; if ( index > - 1 ) { this . notificationHandlers . splice ( index , 1 ) ; } } public notifyUser ( notification ) { this . notificationHandlers . forEach ( ( handler ) => { handler . handleNotification ( notification ) ; } ) ; } public success ( messageText ) { this . notifyUser ( { message : messageText , type : NotificationType . SUCCESS } ) ; } public error ( messageText ) { this . notifyUser ( { message : messageText , type : NotificationType . ERROR } ) ; } public warning ( messageText ) { this . notifyUser ( { message : messageText , type : NotificationType . WARNING } ) ; } public info ( messageText ) { this . notifyUser ( { message : messageText , type : NotificationType . INFO } ) ; } public registerNotificationHandler ( handler ) { this . notificationHandlers . push ( handler ) ; } } export default NotificationServiceImpl ;