I'm upgrading my Angular 5 app to Angular 6 and consequently from rxjs 5 to rxjs 6, I'm experiencing troubles in migrating the following piece of code:
const myObservable = Observable.create(subscriber => {
// do something with the subscriber
}).share();
in particular I'm getting this error:
TypeError: Observable_1.Observable.create(...).share is not a functionTypeError: Observable_1.Observable.create(...).share is not
You need to pipe share() as follows instead of chaining:
const myObservable = Observable.create(subscriber => {
// do something with the subscriber
}).pipe(share());
Also make sure you import share as follows:
import {share} from 'rxjs/operators';
import { Observable } from "rxjs";
...
let obs$ = new Observable(...);
...
Above code should do the trick
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