* Fire the event, notifying all subscribers * * Failure of one or more listeners will not fail this function call. * Failed listeners will be caught and ignored to prevent one listener * from breaking others. * * @param data - The event data to pass to listeners
(data: T)
| 61 | * @param data - The event data to pass to listeners |
| 62 | */ |
| 63 | fire(data: T): void { |
| 64 | for (const listener of this.#listeners) { |
| 65 | try { |
| 66 | listener(data) |
| 67 | } catch (error) { |
| 68 | // Silently ignore listener errors to prevent one failing listener |
| 69 | // from affecting others. Consumers can add error handling in their listeners. |
| 70 | console.error("EventEmitter listener error:", error) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Dispose this event emitter and remove all listeners |
no test coverage detected