From ec4f389b5402f1bc804280ab9f4d32537376eb97 Mon Sep 17 00:00:00 2001 From: Craig Beck Date: Tue, 17 Oct 2023 16:52:43 -0700 Subject: [PATCH] Delay as optional arg --- src/components.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components.ts b/src/components.ts index 81406f26..09bb64f9 100644 --- a/src/components.ts +++ b/src/components.ts @@ -220,7 +220,7 @@ export abstract class Component extends Controller { // // Like component.bind(), will no longer call back once the component is // destroyed, which avoids possible bugs and memory leaks. - debounce(callback: (...args: Parameters) => void, delay: number): (...args: Parameters) => void { + debounce(callback: (...args: Parameters) => void, delay?: number): (...args: Parameters) => void { delay = delay || 0; if (typeof delay !== 'number') { throw new Error('Second argument must be a number'); @@ -267,7 +267,7 @@ export abstract class Component extends Controller { // // Like component.bind(), will no longer call back once the component is // destroyed, which avoids possible bugs and memory leaks. - debounceAsync(callback: (...args: Parameters) => void, delay: number = 0): (...args: Parameters) => void { + debounceAsync(callback: (...args: Parameters) => void, delay?: number): (...args: Parameters) => void { const applyArguments = callback.length !== 1; delay = delay || 0; if (typeof delay !== 'number') {