mitt
- Version 3.0.1
- Published
- 26.4 kB
- No dependencies
- MIT license
Install
npm i mittyarn add mittpnpm add mittOverview
Tiny 200b functional Event Emitter / pubsub.
Index
Functions
Interfaces
Type Aliases
Functions
function mitt
mitt: <Events extends Record<EventType, unknown>>( all?: EventHandlerMap<Events>) => Emitter<Events>;Mitt: Tiny (~200b) functional event emitter / pubsub. mitt
Returns
{Mitt}
Interfaces
interface Emitter
interface Emitter<Events extends Record<EventType, unknown>> {}property all
all: EventHandlerMap<Events>;method emit
emit: { <Key extends keyof Events>(type: Key, event: Events[Key]): void; <Key extends keyof Events>( type: undefined extends Events[Key] ? Key : never ): void;};method off
off: { <Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void; (type: '*', handler: WildcardHandler<Events>): void;};method on
on: { <Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void; (type: '*', handler: WildcardHandler<Events>): void;};Type Aliases
type EventHandlerList
type EventHandlerList<T = unknown> = Array<Handler<T>>;type EventHandlerMap
type EventHandlerMap<Events extends Record<EventType, unknown>> = Map< keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;type EventType
type EventType = string | symbol;type Handler
type Handler<T = unknown> = (event: T) => void;type WildCardEventHandlerList
type WildCardEventHandlerList<T = Record<string, unknown>> = Array< WildcardHandler<T>>;type WildcardHandler
type WildcardHandler<T = Record<string, unknown>> = ( type: keyof T, event: T[keyof T]) => void;Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (21)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/mitt.
- Markdown[](https://www.jsdocs.io/package/mitt)
- HTML<a href="https://www.jsdocs.io/package/mitt"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3220 ms. - Missing or incorrect documentation? Open an issue for this package.
