[Autodesk] debounce with promise
A basic debounce 1 2 3 4 5 6 7 8 9 10 11 12 const _debounce = (fn, delay, immediate = false) => { let timer; return (...args) => { const callNow = immediate && !timer; clearTimeout(timer); timer = setTimeout(() => { timer = null; if (!immediate) fn(...args); }, delay); if (callNow) fn(...args); }; }; debounce with promise When debounce fires during mouse drag but the wrapped function calls an API and returns a Promise, you often want only the last call to run. Lodash’s debounce requires func to be a function: ...