aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/TypedEvent.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-05-03 10:55:33 -0400
committerbobzel <zzzman@gmail.com>2024-05-03 10:55:33 -0400
commitf927a585c75a20629379bcb34d1483c0ca9d8db9 (patch)
treef070e9e64ecaf251e6708b8ce4d722f121a6d039 /src/client/util/TypedEvent.ts
parent723c8b33ade753764d1d02b130c189fb65e20425 (diff)
parent9b424c94d7a89950e9cf3f72e684bd15a61e87ae (diff)
merged with new version of master
Diffstat (limited to 'src/client/util/TypedEvent.ts')
-rw-r--r--src/client/util/TypedEvent.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/client/util/TypedEvent.ts b/src/client/util/TypedEvent.ts
index 90fd299c1..9ef2aa8d7 100644
--- a/src/client/util/TypedEvent.ts
+++ b/src/client/util/TypedEvent.ts
@@ -14,27 +14,27 @@ export class TypedEvent<T> {
on = (listener: Listener<T>): Disposable => {
this.listeners.push(listener);
return {
- dispose: () => this.off(listener)
+ dispose: () => this.off(listener),
};
- }
+ };
once = (listener: Listener<T>): void => {
this.listenersOncer.push(listener);
- }
+ };
off = (listener: Listener<T>) => {
const callbackIndex = this.listeners.indexOf(listener);
if (callbackIndex > -1) this.listeners.splice(callbackIndex, 1);
- }
+ };
emit = (event: T) => {
/** Update any general listeners */
- this.listeners.forEach((listener) => listener(event));
+ this.listeners.forEach(listener => listener(event));
/** Clear the `once` queue */
- this.listenersOncer.forEach((listener) => listener(event));
+ this.listenersOncer.forEach(listener => listener(event));
this.listenersOncer = [];
- }
+ };
- pipe = (te: TypedEvent<T>): Disposable => this.on((e) => te.emit(e));
-} \ No newline at end of file
+ pipe = (te: TypedEvent<T>): Disposable => this.on(e => te.emit(e));
+}