You could leverage a ReplaySubject for that:
EDIT: Different since RxJS 6.x: Note the use of the pipe() method.
class myComponent {
private destroyed$: ReplaySubject<boolean> = new ReplaySubject(1);
constructor(
private serviceA: ServiceA,
private serviceB: ServiceB,
private serviceC: ServiceC) {}
ngOnInit() {
this.serviceA
.pipe(takeUntil(this.destroyed$))
.subscribe(...);
this.serviceB
.pipe(takeUntil(this.destroyed$))
.subscribe(...);
this.serviceC
.pipe(takeUntil(this.destroyed$))
.subscribe(...);
}
ngOnDestroy() {
this.destroyed$.next(true);
this.destroyed$.complete();
}
}
let timer = IntervalObservable.create(60000);
this.subscription = timer.subscribe(
=======>
import {interval} from 'rxjs';
import {takeWhile} from 'rxjs/operators';
....
interval(60000).pipe(takeWhile(()=>this.alive).subscribe(
https://stackoverflow.com/questions/51688768/migration-from-rxjs-5-to-6-intervalobservable