I have an Angular component with observable (BehaviourSubject) set as a class member.
At some point I subscribe to it.
The question is: should I unsubscribe from it in ngOnDestroy() or not?
It's unclear since the lifetime of observable seems to be the same as a lifetime of the component and probably we shouldn't care about memory leak.
Example code:
@Component(...)
class MyComponent implements OnInit {
public subject: BehaviorSubject<string> = new BehaviorSubject('');
public ngOnInit(): void {
this.subject.subscribe(...);
}
}