I'm curious whether it's better to use takeUntil
in each pipe or just once for the entire process?
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
filter((term) => term.length >= 2),
tap(() => (this.searching = true)),
switchMap((term) =>
this.searchService.search(term).pipe(
catchError(() => {
this.searchFailed = true;
return of([]);
}),
takeUntil(this._destroy$)
)
),
tap(() => (this.searching = false)),
takeUntil(this._destroy$)
);