Download Latest Version 3.0.1.tar.gz (7.8 kB)
Email in envelope

Get an email when there's a new version of Mitt

Home / 3.0.0
Name Modified Size InfoDownloads / Week
Parent folder
3.0.0.tar.gz 2021-06-23 7.6 kB
3.0.0.zip 2021-06-23 10.6 kB
README.md 2021-06-23 898 Bytes
Totals: 3 Items   19.0 kB 0

Mitt 3.0 adds a couple nice new features.

1. Remove all handlers of a type:

Calling .off("type") with no handler argument now removes all listeners of that type (#123, [#124], [#129] - thanks @sealice!).

2. New, stronger typing:

It's now possible to define explicit types for events and their arguments (#114, thanks @iyegoroff & @deskoh):

:::ts
import mitt from 'mitt';
const events = mitt<{ foo: string }>();
events.on('foo', e => {});  // `e` is inferred to be of type string!
events.emit('foo', 42);  // TypeError: got a number, expected a string

3. Package Exports:

As of 3.0.0, the mitt package now uses Package Exports. This shouldn't change usage or anything, it just means you're more likely to end up using the ES Module version of Mitt when running in Node.

Source: README.md, updated 2021-06-23