import { Injectable } from '@angular/core' ; import { Subject } from 'rxjs' ; export interface ErrorValue { error : string ; reason : string ; } @ Injectable ( ) export class ErrorService { private onError : Subject < ErrorValue > = new Subject < ErrorValue > ( ) ; onError$ = this . onError . asObservable ( ) ; showError ( err , reason ? ) { const errorValue = { error : err , reason } ; this . onError . next ( errorValue ) ; } hide ( ) { this . onError . next ( null ) ; } }