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]> = {
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user