There is a EventEmitter:
@Output() edit: EventEmitter<any> = new EventEmitter();
How to check if anyone is subscribed to EventEmitter in Angular?
Angular EventEmitter
is an RXJS Subject
:
class EventEmitter<T> extends Subject<T>
Subject.observed: bool
-- true if there are 1 or more subscribers
/**
* A Subject is a special type of Observable that allows values to be
* multicasted to many Observers. Subjects are like EventEmitters.
*
* Every Subject is an Observable and an Observer. You can subscribe to a
* Subject, and you can call next to feed values as well as error and complete.
*/
export class Subject<T> extends Observable<T> implements SubscriptionLike {
...
private currentObservers = new Map<number, Observer<T>>()
get observed() {
return this.currentObservers.size > 0;
}
EventEmitter
, consider BehaviorSubject
or ReplaySubject
.