Reputation: 4217
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();
}
Upvotes: 3
Views: 1152
Reputation: 11243
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
.
Upvotes: 5