npm mitt 3.0.0

latest release: 3.0.1
3 years ago

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

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.

Don't miss a new mitt release

NewReleases is sending notifications on new releases.