import { Injectable } from '@angular/core' ; import { Subject , Subscription , Observable } from 'rxjs' ; import { filter , map } from 'rxjs/operators' ; @ Injectable ( { providedIn : 'root' } ) export class EventBusService { private subject$ = new Subject ( ) ; on ( event , action ) { return this . subject$ . pipe ( filter ( ( e ) => e . name === event ) , map ( ( e ) => e . value ) ) . subscribe ( action ) ; } emit ( event ) { this . subject$ . next ( event ) ; } } export class EmitEvent { constructor ( public name , public value ? ) { } } export enum Events { CustomerSelected }