* Register an event handler for the given type. * @param {string|symbol} type Type of event to listen for, or `'*'` for all events * @param {Function} handler Function to call in response to given event * @memberOf mitt
(type: Key, handler: GenericEventHandler)
| 64 | * @memberOf mitt |
| 65 | */ |
| 66 | on<Key extends keyof Events>(type: Key, handler: GenericEventHandler) { |
| 67 | const handlers: Array<GenericEventHandler> | undefined = all!.get(type); |
| 68 | if (handlers) { |
| 69 | handlers.push(handler); |
| 70 | } else { |
| 71 | all!.set(type, [handler] as EventHandlerList<Events[keyof Events]>); |
| 72 | } |
| 73 | }, |
| 74 | |
| 75 | /** |
| 76 | * Remove an event handler for the given type. |
nothing calls this directly
no outgoing calls
no test coverage detected