Comments (8)
You can easily do both.
.emit(type, ...rest)
.on(type, (type, ...rest) => {})
.on('*', (type, ...rest) => {})
from mitt.
You might be surprised how convenient *
is! Some uses I've had for it over the years:
- logging (example:
on('*', console.log)
) - refiring modified or aggregate events (example:
on('log:debounced')
) - collating events between two emitters (example: inside/outside a worker)
- implementing rudimentary event bubbling (listen to child's
*
, refire ife.bubble
) - even implementing case-insensitive event handling 💃
from mitt.
hmm.. yep, forgot about that
from mitt.
So finally, I just tried to see what I'll get if I merge everything ( #8, #11, #12 + this one #13 ) and it is 210 bytes which looks good number :P :)
from mitt.
Nice! Though I might have an interesting thought that changes your mind about the multiple arguments thing from @bevacqua:
from mitt.
FWIW, I would use support for multiple arguments before using *
.
from mitt.
I'm absolutely agree. Working (emitting) only one argument is cool and very clean. So yea, I can agree to remove that extra second argument from #19, but we should mention that in the docs that emit
can only emit one argument. :)
from mitt.
Yea. Closing per f4c60f4
from mitt.
Related Issues (20)
- Nuxt3 issues ? HOT 2
- Persist events that not yet have a handler HOT 1
- Is it possible to use mitt across two different tabs? Or via an iframe? HOT 10
- [TypeScript] define events interface HOT 3
- Mitt - some problems HOT 1
- Typescript issue with `moduleResolution: NodeNext` HOT 1
- `dist/mitt.mjs` must not have a sourcemap HOT 5
- mitt extension
- Unpkg CDN Version is down HOT 1
- Using Ag-grid cell renderer with Mitt HOT 1
- Bug: type issue in [email protected]+ with esm HOT 2
- Could we have a minor update? HOT 1
- Doesn't work with typescript 5 moduleResolution set to bundler HOT 11
- vue3 options methods use mitt Invalid HOT 1
- why use sllice & map HOT 2
- Can't pass multiple arguments with emit HOT 2
- How to declare type of event parameter when listen for event HOT 1
- error TS2349: This expression is not callable when using "module": "NodeNext". HOT 5
- Uncaught TypeError: (0 , mitt__WEBPACK_IMPORTED_MODULE_5__.default)(...) is not a function
- Emit issue on Vue 3. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mitt.