* Adds an event listener for the given event string. * * @param {string} event * @param {Function} handler * @param ctx * @param {boolean} once * @returns
(event: string, handler: AnyHandler, ctx?: unknown, once = false)
| 20 | * @returns |
| 21 | */ |
| 22 | on(event: string, handler: AnyHandler, ctx?: unknown, once = false) { |
| 23 | if (isUndefined(this.bindings)) { |
| 24 | this.bindings = {}; |
| 25 | } |
| 26 | if (isUndefined(this.bindings[event])) { |
| 27 | this.bindings[event] = []; |
| 28 | } |
| 29 | this.bindings[event]?.push({ handler, ctx, once }); |
| 30 | |
| 31 | return this; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Adds an event listener that only fires once for the given event string. |
no test coverage detected