Use variable for debounce addtion
This commit is contained in:
+10
-2
@@ -57,9 +57,13 @@ export class EventEmitter<T extends EventMap> {
|
|||||||
const listenerEntry: ListenerEntry<T[K]> = {
|
const listenerEntry: ListenerEntry<T[K]> = {
|
||||||
listener,
|
listener,
|
||||||
wrappedListener,
|
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.
|
// Add the listener entry to the listeners map.
|
||||||
this.#listeners.get(type)?.add(listenerEntry);
|
this.#listeners.get(type)?.add(listenerEntry);
|
||||||
|
|
||||||
@@ -94,9 +98,13 @@ export class EventEmitter<T extends EventMap> {
|
|||||||
listener,
|
listener,
|
||||||
wrappedListener: debouncedListener,
|
wrappedListener: debouncedListener,
|
||||||
once: true,
|
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.
|
// Add the listener entry to the listeners map.
|
||||||
this.#listeners.get(type)?.add(listenerEntry);
|
this.#listeners.get(type)?.add(listenerEntry);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user