I have a hard time understanding RxJs. The breaking changes between 5 and 6 are hard for me to understand.
I have the following code and the following issues.
I checked the changelog and the recommendations for fixing breaking changes and I wasn't able to sort out what I need to do. The way I understand it, the code I have is old and doesn't use the pipe operator but that's about all I've been able to figure out.
let polling = Observable.interval(2000)
.switchMap(() => this.http.get(this.videoStatusURL + this.taskID))
.subscribe(
(data) => {
if (data["state"] === "SUCCESS") {
//get final video here
console.log("polling succeeded");
this.downloadFinalVideo();
polling.unsubscribe();
}
},
error => this.handleError(error));
See the section on pipe syntax in the migration doc, operators must be invoked by calling .pipe(), so you need to do something like
import { interval } from 'rxjs';
import { switchMap } from 'rxjs/operators';
let polling = interval(2000)
.pipe(switchMap(() => this.http.get(this.videoStatusURL + this.taskID)))
.subscribe(
(data) => {
if (data["state"] === "SUCCESS") {
//get final video here
console.log("polling succeeded");
this.downloadFinalVideo();
polling.unsubscribe();
}
},
error => this.handleError(error));
Alternatively, you could install rxjs-compat, however this is just a compatibility layer and you should really be using the pipe syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With