diff --git a/src/utils/helpers/debounce.ts b/src/utils/helpers/debounce.ts index 86357141..8ed86d0c 100644 --- a/src/utils/helpers/debounce.ts +++ b/src/utils/helpers/debounce.ts @@ -1,11 +1,11 @@ -export const debounce = ( +export function debounce( callback: (...args: Params) => void, delay: number -): ((...args: Params) => void) => { +): ((...args: Params) => void) { let timer: ReturnType; - return function (...args: Params) { + return function (this: any, ...args: Params) { clearTimeout(timer); - timer = setTimeout(() => callback(...args), delay); + timer = setTimeout(() => callback.apply(this, args), delay); }; }; diff --git a/src/utils/helpers/throttle.ts b/src/utils/helpers/throttle.ts index 95182f54..e7d15155 100644 --- a/src/utils/helpers/throttle.ts +++ b/src/utils/helpers/throttle.ts @@ -4,9 +4,9 @@ export const throttle = ( ): ((...args: Params) => void) => { let isCalled = false; - return function (...args) { + return function (this: any, ...args) { if (!isCalled) { - callback(...args); + callback.apply(this, args); isCalled = true; setTimeout(() => { isCalled = false;