import { Component , Input } from '@angular/core' ; import { ToastService } from '../toast.service' ; @ Component ( { selector : 'cmdb-toast-component' , templateUrl : './toast-component.component.html' , styleUrls : [ './toast-component.component.scss' ] , } ) export class ToastComponentComponent { private _toast : any = { } ; @ Input ( ) public set toast ( value ) { this . _toast = value ; } public get toast ( ) : any { return this . _toast ; } constructor ( public toastService ) { } param time parse ( time ) { if ( time ) { return 'progressBars ' + time . toString ( ) + ' s linear' ; } return 'progressBar 3.5s linear' ; } param time param toast waitTillDisposal ( time , toast ) { function delay ( ms ) { return new Promise ( resolve => { setTimeout ( resolve , ms ) ; } ) ; } ( async ( ) => { await delay ( time ) ; if ( toast ) { this . toastService . remove ( toast ) ; } } ) ( ) ; } }