We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 95ca253 commit ea424bbCopy full SHA for ea424bb
Client-Side Components/UX Client Script Include/Reusable Debounce/DebounceUtil.js
@@ -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