I have BaseComponent class in my Angular app, which implements destroy$: Subject<void> for observables. Every time I subscribe to service, I'm doing:
this.myService.loadData()
    .pipe(takeUntil(this.destroy$))
    .subscribe(data => this.userData = data);
I want to avoid writing .pipe(takeUntil(this.destroy$)) everywhere and I'm wondering, is there any way to create extension method for observable and handle takeUntil there? for example to move .pipe(takeUntil(this.destroy$)) to my custom method ifAlive and make it look like this:
this.myService.loadData()
    .isAlive()
    .subscribe(...);
Any ideas?
 
     
    