Rxjs 如何检测承诺值的变化?

Rxjs 如何检测承诺值的变化?,rxjs,rxjs5,Rxjs,Rxjs5,我想轮询一些函数,这些函数返回承诺并检测解析值中的更改。我需要在这里添加interval操作符 const observer = (newValue) => { console.log('Change detected', newValue); } Observable.fromPromise(getValue()) .distinctUntilChanged((oldValue, newValue) => oldValue == newValue) .subscrib

我想轮询一些函数,这些函数返回承诺并检测解析值中的更改。我需要在这里添加
interval
操作符

const observer = (newValue) => {
  console.log('Change detected', newValue);
}

Observable.fromPromise(getValue())
  .distinctUntilChanged((oldValue, newValue) => oldValue == newValue)
  .subscribe(observer);
一个典型的

Observable.interval(1000)
  .switchMap(() => Observable.fromPromise(getValue())
  .distinctUntilChanged((oldValue, newValue) => oldValue == newValue)
  .subscribe(observer);