Skip to content
Myr

README.md

This file

Path

README.md

54 lines · 1.6 KiB · Markdown

Last changed by

Initial commit! 🚀Jason Millerbefore adoptione77a42c

History of this file

Take it

Initial commit! 🚀Jason Millerbefore adoptione77a42c

lines 1–54
1# `mitt`
23[![NPM](https://img.shields.io/npm/v/mitt.svg?style=flat)](https://www.npmjs.org/package/mitt)4[![travis-ci](https://travis-ci.org/developit/mitt.svg?branch=master)](https://travis-ci.org/developit/mitt)56**Tiny (~200b) functional event emitter / pubsub.**78**It's tiny:** no dependencies and only **190 bytes** when gzipped _(250b without)_.910* * *1112## Installation1314```sh15npm install --save mitt16```1718* * *1920## API2122### mitt2324Mitt: Tiny (~200b) functional event emitter / pubsub.2526Returns **Mitt** 2728#### on2930Register an event handler for the given type.3132**Parameters**3334- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of event to listen for, or `"*"` for all events35- `handler` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function to call in response to the given event3637#### off3839Remove an event handler for the given type.4041**Parameters**4243- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of event to unregister `handler` from, or `"*"`44- `handler` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Handler function to remove4546#### emit4748Invoke all handlers for the given type.49If present, `"*"` handlers are invoked prior to type-matched handlers.5051**Parameters**5253- `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The event type to invoke54- `event` **\[Any]** An event object, passed to each handler