MCPcopy Index your code
hub / github.com/CoderLine/alphaTab / EventEmitter

Class EventEmitter

packages/alphatab/src/EventEmitter.ts:45–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 * @internal
44 */
45export class EventEmitter implements IEventEmitter {
46 private _listeners: (() => void)[] = [];
47 private readonly _fireOnRegister: (() => boolean) | undefined;
48
49 public constructor(fireOnRegister: (() => boolean) | undefined = undefined) {
50 this._fireOnRegister = fireOnRegister;
51 }
52
53 public on(value: () => void): () => void {
54 this._listeners.push(value);
55 if (this._fireOnRegister?.()) {
56 value();
57 }
58 return () => {
59 this.off(value);
60 };
61 }
62
63 public off(value: () => void): void {
64 this._listeners = this._listeners.filter(l => l !== value);
65 }
66
67 public trigger(): void {
68 for (const l of this._listeners) {
69 l();
70 }
71 }
72}
73
74/**
75 * @partial

Callers 6

AlphaTabViewClass · 0.85
AndroidSynthOutputClass · 0.85
AndroidUiFacadeClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected