Skip to content

Commit ea424bb

Browse files
authored
Add the UX Client Script Include
1 parent 95ca253 commit ea424bb

File tree

1 file changed

+18
-0
lines changed
  • Client-Side Components/UX Client Script Include/Reusable Debounce

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function include() {
2+
class DebounceUtil {
3+
4+
/**
5+
* @param callbackFunc - callback function following timeout
6+
* @param timeout - debounce timeout
7+
* @param helpers - the helpers object passed from a UX Client Script
8+
*/
9+
static debounce(callbackFunc, timeout = 750, helpers) {
10+
let timer;
11+
return (...args) => {
12+
helpers.timing.clearTimeout(timer); // Clear anything currently in place
13+
timer = helpers.timing.setTimeout(() => { callbackFunc.apply(this, args); }, timeout);
14+
};
15+
}
16+
}
17+
return DebounceUtil;
18+
}

0 commit comments

Comments
 (0)