Last active
September 27, 2019 08:50
-
-
Save pointofpresence/618eb13dab141889537068a711e63aad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash' | |
export function debounceRequest({ context, cb, debounceId = 'debounceId', interval = 1000 }) { | |
const id = `__debounce__${ debounceId }__` | |
if(_.isFunction(cb)) { | |
context[id] && context[id].cancel() | |
context[id] = _.debounce(cb, interval, false) | |
context[id]() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment