Rxjs 6 equivalent of Observable.create(subscriber -> {...}).share() Rxjs 6 equivalent of Observable.create(subscriber -> {...}).share() angular angular

Rxjs 6 equivalent of Observable.create(subscriber -> {...}).share()


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