Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
2.1.0.tar.gz | 2020-07-15 | 6.2 kB | |
2.1.0.zip | 2020-07-15 | 9.0 kB | |
README.md | 2020-07-15 | 972 Bytes | |
Totals: 3 Items | 16.2 kB | 0 |
Mitt 2 is out of preview!
-
It's written in TypeScript and ships type definitions (#107, thanks again @jackfranklin!)
-
Event handlers are now stored in a Map instead of an Object.
Upgrading: If you aren't passing an object to
mitt({})
, version 2 is backwards-compatible. If you were, turn your object into a map:```diff -const handlers = { - foo: [() => alert(1)] -}; +const handlers = new Map(); +handlers.set('foo', [() => alert(1)]);
const events = mitt(handlers); ```
-
The event handler Map is now exposed as
.all
: (#105, thanks @jaylinski!)```js const events = mitt(); events.on('foo', () => alert(1)); events.on('bar', () => alert(2));
// access handlers directly if needed: events.all.get('foo') // [() => alert(1)]
// remove all event handlers: events.all.clear(); ```