在 RxJS 4.0 中,我可以执行以下操作:
let clicks = Observable.fromEvent(board.canvas, 'click'),
keydowns = Observable.fromEvent(document, 'keydown')
.filter((e) => e.keyCode === 32);
return Observable
.merge(clicks, keydowns)
.sample(200).
.timestamp();