Skip to content Skip to sidebar Skip to footer

Subscribe Method Is Not Triggered With Rxjs

I'm quite a beginner in RxJS, I'm currently using RxJS@5 and don't understand a behavior of my code const currentExtentMinutes$ = initialExtentMinutes$ .merge(selectedExtentMin

Solution 1:

I think you might be yet another victim of the hot vs. cold nature of observables. Basically currentExtentMinutes is subscribed twice, once in the first code snippet, and the second time with the use of withLatestFrom. Every subscription to a cold observable will restart the producer, producing values anew (for more details have a look here).

If that is the problem here, then it should be enough to 'share' your cold observable with

const currentExtentMinutes$ = initialExtentMinutes$
    .merge(selectedExtentMinutes$)
    .distinctUntilChanged()
    .share()

Post a Comment for "Subscribe Method Is Not Triggered With Rxjs"