import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; @Injectable({ providedIn: 'root', }) export class UpdateNotifierService { private updateSubjects: Record> = { task: new Subject(), contact: new Subject(), }; taskUpdated$ = this.updateSubjects['task'].asObservable(); contactUpdated$ = this.updateSubjects['contact'].asObservable(); notifyUpdate(type: 'task' | 'contact', payload?: string) { this.updateSubjects[type].next(payload ?? ''); } }