0👍
Ok, first of all it’s a Laravel Echo
code. It may be using pusher behind the scenes, but saying it’s a pusher code is slightly incorrect.
Then, if I understand you right, you need some kind of debounce function. For example lodash
offers one.
const debouncedFunction = _.debounce(() => {
this.fetchData()
}, 5000);
Echo.private('channel').listen('.foobar', e => {
debounced()
})
debounce
will create debounced version of function which you can then call, or even cancel, because it comes with cancel
method.
debouncedFunction.cancel()
Source:stackexchange.com