What is the best way to unsubscribe in RxJS 6?
My 'old' RxJS 5 code looks this
export class MyComponent implements OnInit, OnDestroy {
private ngUnsubscribe: Subject<any> = new Subject();
this.myService.myEventEmitter
.takeUntil(this.ngUnsubscribe)
.subscribe(this.onDataPolling.bind(this));
public ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
}
On migration to RxJS 6 i run rxjs-5-to-6-migrate
and got
this.myService.myEventEmitter.pipe(
takeUntil(this.ngUnsubscribe))
.subscribe(this.onDataPolling.bind(this));
but this is not working because EventEmitter has no pipe method.
What is the best way to unsubscribe in RxJS 6?
Edit: This did work after a clean install and is the best way to unsubscribe in RxJS 6.