我有兩個觀察對象Observable.of(0, animationFrame)
& Observable.fromEvent(window, 'scroll')
。我想合併它們,這樣我的renderScrollBar(event)
只在animationFrame的tick上被調用。如何將rrjjs中的Scheduler.animationFrame和fromEvent(window,'scroll')流結合起來?
Observable.fromEvent(window, 'scroll')
.map((event: any) => event.currentTarget)
.subscribe((event) => {
this._renderScrollBar(event);
});
let x = 0;
Observable.of(0, animationFrame)
.repeat()
.takeUntil(Observable.timer(1000))
.subscribe(() => console.log(x++));
}
我不認爲有任何簡單的方法來運行在RxJS每animationFrame動作。 – martin
是[zip](http://reactivex.io/documentation/operators/zip.html)您正在查找的行爲? – concat
@concat我認爲你能夠在答案中做出樣本?我會試試看,並將其標記爲正確 –