Ability to use on Observable vs immediately before each subscribe
andreaSplice opened this issue · 1 comments
andreaSplice commented
Reading your documentation and tests, I wasn't able to find support or discouragement for using UntilDestroyed on an observable and if it would provide coverage for multiple subscriptions to be destroyed.
For example:
myObservable$ = this.data$.pipe(UntilDestroyed(this));
sub1 = this.myObservable$.subscribe(()=> {});
sub2 = this.myObservable$.map(x => x+2).subscribe(() => {});
Would both, neither, or one of sub1 or sub2 be destroyed?
arturovt commented
The untilDestroyed acts as a takeUntil, so you can put there takeUntil and “try” to see what happens. In your case there’s no memory leak, but RxJS team has been always saying that takeUntil should be at the end.