import { BehaviorSubject, Observable } from 'rxjs'; import { EventEmitter } from '@angular/core'; export class EventInputManager { private stateSubject: BehaviorSubject; state$: Observable; constructor( initialValue: T | null, private eventEmitter: EventEmitter ) { this.stateSubject = new BehaviorSubject(initialValue); this.state$ = this.stateSubject.asObservable(); } /** * Update the value and emit the event. */ next(newValue: T): void { this.stateSubject.next(newValue); // Update state if (this.eventEmitter) { this.eventEmitter.emit(newValue); // Emit event } } /** * Get the current value. */ get value(): T | null { return this.stateSubject.value; } }