import { EventEmitter, Injectable } from '@angular/core'; import { IcsToast } from './types/ics-toast'; import { IcsToastType } from './types/ics-toast-type'; @Injectable() export class IcsToastService { public toast$: EventEmitter; constructor() { this.toast$ = new EventEmitter(); } public success(message: string, keepAfterRouteChange = false) { this.next({ icon: IcsToastType.SUCCESS, message: message, keepAfterRouteChange: keepAfterRouteChange }); } public error(message: string, keepAfterRouteChange = false) { this.next({ icon: IcsToastType.ERROR, message: message, keepAfterRouteChange: keepAfterRouteChange }); } public loading(message: string, keepAfterRouteChange = false) { this.next({ icon: IcsToastType.LOADING, message: message, keepAfterRouteChange: keepAfterRouteChange }); } public clear() { this.next(null); } private next(toast: IcsToast) { this.toast$.emit(toast); } }