Reputation: 3464
I want to poll some function that returns promises and detect change in resolved values. I need to somehow add interval
operator here.
const observer = (newValue) => {
console.log('Change detected', newValue);
}
Observable.fromPromise(getValue())
.distinctUntilChanged((oldValue, newValue) => oldValue == newValue)
.subscribe(observer);
Upvotes: 1
Views: 416
Reputation: 16882
A typical case for switchMap
Observable.interval(1000)
.switchMap(() => Observable.fromPromise(getValue())
.distinctUntilChanged((oldValue, newValue) => oldValue == newValue)
.subscribe(observer);
Upvotes: 3