【发布时间】:2020-12-05 12:56:39
【问题描述】:
我正在使用这样的 lodash 油门
const throttledFetch = _.throttle(fetch, 10000, { 'leading': false });
我需要在我从 ws 获得的某个通知事件时触发它。所以我的想法是,如果我几乎同时收到 10 条通知,让 fetch 函数在等待 10 秒时只触发一次。
相反,获取函数在 10 秒延迟后被触发了 10 次。
我该如何解决这个问题?我可以使用任何其他方法。
欢迎提出建议
【问题讨论】:
-
fetch函数长什么样子? -
() => {dispatch(someAction())}
标签: javascript reactjs lodash throttling