From 699c441c594ce1a8d300a34c58c15e1d393c692d Mon Sep 17 00:00:00 2001 From: Ankit Gupta <ankit.gupta@gspann.com> Date: Mon, 13 May 2024 18:51:41 +0530 Subject: [PATCH 1/2] added debounce to export --- scripts/aem.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/aem.js b/scripts/aem.js index 9ac8b05..289e9ab 100644 --- a/scripts/aem.js +++ b/scripts/aem.js @@ -895,6 +895,7 @@ export { passFormMeetingConfig, loadFormDelayed, getFormMeetingConfig, + debounce, }; export function debounce(func, timeout = 300) { From bc4a1d780c273fbdfc4db1f2e99c84ae8d01ab9c Mon Sep 17 00:00:00 2001 From: Ankit Gupta <ankit.gupta@gspann.com> Date: Mon, 13 May 2024 19:05:30 +0530 Subject: [PATCH 2/2] code update for debounce --- scripts/aem.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/aem.js b/scripts/aem.js index 289e9ab..5d125e0 100644 --- a/scripts/aem.js +++ b/scripts/aem.js @@ -860,6 +860,14 @@ async function waitForLCP(lcpBlocks) { }); } +function debounce(func, timeout = 300) { + let timer; + return (...args) => { + clearTimeout(timer); + timer = setTimeout(() => { func.apply(this, args); }, timeout); + }; +} + init(); export { @@ -897,11 +905,3 @@ export { getFormMeetingConfig, debounce, }; - -export function debounce(func, timeout = 300) { - let timer; - return (...args) => { - clearTimeout(timer); - timer = setTimeout(() => { func.apply(this, args); }, timeout); - }; -}