我对 ReactiveJS 比较陌生,我希望实现以下目标:
只有在时间戳 (updated_at) 与上一个时间戳不同时才发出值(对象)。
var checkJobsRx = new Rx.Subject();
checkJobsRx
.dosomethinghere()
.subscribe(function (data) {})
最佳答案
请阅读有关 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) {})
关于javascript - RxJS 与最后一个比较并发出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34108730/