Suppose a component has the following attributes:
private foo$: Observable<Array<SomeType>>;
private bar: SomeOtherType;
Eventually, they are assigned values...
this.foo$ = someSubject.pipe(switchMap(...whatever...
this.bar = new SomeOtherType(...whatever...
At a certain point, I need to clear these properties for various reasons. By clearing, I mean removing their values and setting them back to their initial state.
Setting them to undefined
is not desirable as it would result in losing their "type information". It is important for TypeScript and Angular to recognize that they remain an Observable and an object of SomeOtherType.
What alternatives do I have?