Skip to content

3.0.0

Compare
Choose a tag to compare
@developit developit released this 23 Jun 20:58
· 8 commits to main since this release
13905bd

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.