Use variable for debounce addtion

This commit is contained in:
2026-08-07 01:44:20 +00:00
parent 3664464903
commit a948671251
+10 -2
View File
@@ -57,9 +57,13 @@ export class EventEmitter<T extends EventMap> {
const listenerEntry: ListenerEntry<T[K]> = {
listener,
wrappedListener,
...(debounceMilliseconds !== undefined ? { debounceTime: debounceMilliseconds } : {}),
};
// Set the debounce time if specified.
if (debounceMilliseconds && debounceMilliseconds > 0) {
listenerEntry.debounceTime = debounceMilliseconds;
}
// Add the listener entry to the listeners map.
this.#listeners.get(type)?.add(listenerEntry);
@@ -94,9 +98,13 @@ export class EventEmitter<T extends EventMap> {
listener,
wrappedListener: debouncedListener,
once: true,
...(debounceMilliseconds !== undefined ? { debounceTime: debounceMilliseconds } : {}),
};
// Set the debounce time if specified.
if (debounceMilliseconds && debounceMilliseconds > 0) {
listenerEntry.debounceTime = debounceMilliseconds;
}
// Add the listener entry to the listeners map.
this.#listeners.get(type)?.add(listenerEntry);