By dig into the angular form implementation I found the angular form valueChanges/statusChanges observable are EventEmitters. Is it necessary to unsubscribe these observables? since when use EventEmitters alone we don't unsubscribe?
_initObservables() {
(this as{valueChanges: Observable<any>}).valueChanges = new EventEmitter();
(this as{statusChanges: Observable<any>}).statusChanges = new EventEmitter();
}
It is always a good practice to unsubscribe if notification is no longer required. Most of the time you can put into ngDestroy() function not necessarily.
Is it always required to Unsubscribe ?
No, If EventEmitter or Subject or Observable in same scope (Component or Service ) where Subscription is, then no need to destroy since all reference for all will be removed altogether.
In short, make sure Observable is unsubscribe if scope are different for Subscription and Observable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With