MCPcopy Create free account
hub / github.com/coder/ghostty-web / EventEmitter

Class EventEmitter

lib/event-emitter.ts:3–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import type { IDisposable, IEvent } from './interfaces';
2
3export class EventEmitter<T> {
4 private listeners: Array<(arg: T) => void> = [];
5
6 fire(arg: T): void {
7 for (const listener of this.listeners) {
8 listener(arg);
9 }
10 }
11
12 event: IEvent<T> = (listener) => {
13 this.listeners.push(listener);
14 return {
15 dispose: () => {
16 const index = this.listeners.indexOf(listener);
17 if (index >= 0) {
18 this.listeners.splice(index, 1);
19 }
20 },
21 };
22 };
23
24 dispose(): void {
25 this.listeners = [];
26 }
27}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…