I have been working with Subjects and there is a .subscribe()
in a specific class. Emitting values to this class from different other classes has resulted in the subscribe function being triggered multiple times, yet I am unsure of where these emits are coming from.
Is there a method to identify the class or reference from which the emit (.next<T>
) was initiated?
Expected behavior:
In the service svc:
obs: Subject<Date> = new Subject<Date>();
Class 1:
svc.obs.next(new Date());
Class n:
svc.obs.next(new Date());
Subscriber:
svc.obs.subscribe((date) => {
console.log("Triggered from: " + svc.obs.getSource().classname); // Desired output: "Triggered from: SomeNamespace.Classname"
});