我是 Rxjs Observables 的新手,我需要使用 Rxjs 实现限制。
在下划线中,我们使用以下行来做到这一点 -
_.throttle(functionName, timespan, {trailing : true/false}).
请协助如何使用可观察量做到这一点。
最佳答案
只需使用 throttle
运算符。
Rx.Observable.fromEvent(window, 'mousemove')
.throttle(500)
.subscribe(x => console.log(x));
它将限制事件,以便在单个 500 毫秒窗口内只能通过一个事件。
关于javascript - _.throttle 使用 RXJS 可观察量实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38651479/