You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to create hot observable i was following the below approach
Create Observable from interval()
Publish that Observable using publish() to create a ConnectableObservable
Call connect() on that ConnectableObservable
But I am getting the below error -
Property 'connect' does not exists on type Observable. I knowconnectexists only onConnectableObservable` but in Rxjs 5 this below code was working fine.
let $hotstream = Observable.interval(1000)
.take(6)
.publish();
$hotstream.connect();
RxJS version: 6.0.0
Code to reproduce: This is my code for Rxjs 6
let $hotstream = interval(1000).pipe(take(6),publish());
$hotstream.connect()
Expected behavior: Should be able to call connect after using publish.
Actual behavior: I have to perform an explicit cast like below to call connect. let $hotstream = <ConnectableObservable<any>>interval(1000).pipe(take(6),publish()); $hotstream.connect();
P.S The same issue is occurring for refCount.
Additional information: Is it required to do an explicit casting like this to call connect() now?
I also noticed few changes in the publish method from 5x to 6x version.
in 5x version the below signature was called - export function publish<T>(this: Observable<T>): ConnectableObservable<T>;
But in 6x version the signature has changed to - export function publish<T>(): UnaryFunction<Observable<T>, ConnectableObservable<T>>; which basically returns a function that accepts an Obervable parameter and returns a ConnectableObservable<T>. So what is the best way to call connect in 6x version?
The text was updated successfully, but these errors were encountered:
In order to create hot observable i was following the below approach
interval()
publish()
to create a ConnectableObservableconnect()
on that ConnectableObservableBut I am getting the below error -
Property 'connect' does not exists on type
Observable. I know
connectexists only on
ConnectableObservable` but in Rxjs 5 this below code was working fine.RxJS version: 6.0.0
Code to reproduce: This is my code for Rxjs 6
Expected behavior: Should be able to call
connect
after usingpublish
.Actual behavior: I have to perform an explicit cast like below to call
connect
.let $hotstream = <ConnectableObservable<any>>interval(1000).pipe(take(6),publish()); $hotstream.connect();
P.S The same issue is occurring for
refCount
.Additional information: Is it required to do an explicit casting like this to call
connect()
now?I also noticed few changes in the
publish
method from 5x to 6x version.in 5x version the below signature was called -
export function publish<T>(this: Observable<T>): ConnectableObservable<T>;
But in 6x version the signature has changed to -
export function publish<T>(): UnaryFunction<Observable<T>, ConnectableObservable<T>>;
which basically returns a function that accepts an Obervable parameter and returns aConnectableObservable<T>
. So what is the best way to callconnect
in 6x version?The text was updated successfully, but these errors were encountered: