diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | mitt.d.ts | 14 |
2 files changed, 10 insertions, 10 deletions
@@ -57,7 +57,7 @@ You can find the library on `window.mitt`. ```js import mitt from 'mitt' -let emitter = mitt() +const emitter = mitt() // listen to an event emitter.on('foo', e => console.log('foo', e) ) @@ -77,8 +77,8 @@ emitter.off('foo', onFoo) // unlisten ### Typescript ```ts -import * as mitt from 'mitt'; -let emitter: mitt.Emitter = new mitt(); +import mitt from 'mitt'; +const emitter: mitt.Emitter = mitt(); ``` ## Examples & Demos @@ -8,26 +8,26 @@ declare namespace mitt { type Handler = (event?: any) => void; interface MittStatic { - new(all?: {[key: string]: Handler}): Emitter; + (all?: {[key: string]: Handler}): Emitter; } interface Emitter { /** * Register an event handler for the given type. - * + * * @param {string} type Type of event to listen for, or `"*"` for all events. * @param {Handler} handler Function to call in response to the given event. - * + * * @memberOf Mitt */ on(type: string, handler: Handler): void; /** * Function to call in response to the given event - * + * * @param {string} type Type of event to unregister `handler` from, or `"*"` * @param {Handler} handler Handler function to remove. - * + * * @memberOf Mitt */ off(type: string, handler: Handler): void; @@ -35,10 +35,10 @@ declare namespace mitt { /** * Invoke all handlers for the given type. * If present, `"*"` handlers are invoked prior to type-matched handlers. - * + * * @param {string} type The event type to invoke * @param {any} [event] An event object, passed to each handler - * + * * @memberOf Mitt */ emit(type: string, event?: any): void; |
