import { Injectable } from '@angular/core' ; import { EventEmitter } from '@app/event' ; import { ProcessStorageService } from '@app/storage' ; import { Notification } from './notification' ; const NOTIFICATION_DATA_KEY = 'NOTIFICATION_DATA' ; @ Injectable ( { providedIn : 'root' } ) export class NotificationService { constructor ( private readonly storage ) { } public get notification$ ( ) : EventEmitter < Notification > { return this . storage . get ( NOTIFICATION_DATA_KEY , ( ) => new EventEmitter < Notification > ( ) ) ; } public show ( message , duration = 1000 * 3 ) { const notification = { message , duration } ; this . notification$ . next ( notification ) ; } }