MCPcopy Index your code
hub / github.com/developit/mitt / on

Function on

src/index.ts:66–73  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected