RxJS比较最后并发出

Tin*_*ino 0 javascript reactive-programming rxjs

我对ReactiveJS相当陌生,我想实现以下目标:

仅在值(对象)与上一个不同的时间戳(updated_at)时才发出。

var checkJobsRx = new Rx.Subject();
checkJobsRx
.dosomethinghere()
.subscribe(function (data) {})
Run Code Online (Sandbox Code Playgroud)

Won*_*Kim 5

请阅读有关distinctUntilChanged()的文档。http://reactivex.io/documentation/operators/distinct.html

我猜下面的代码是这个问题的答案。(仅添加了1行)

var checkJobsRx = new Rx.Subject();
  checkJobsRx
 .dosomethinghere()
 .distinctUntilChanged(function(job) { return job.updated_at })
 .subscribe(function (data) {})
Run Code Online (Sandbox Code Playgroud)