-
Notifications
You must be signed in to change notification settings - Fork 481
make on() to return unsubscribe function #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Love the idea! Need to figure out a way to keep this under 200b though ;) |
|
Save some space by removing the |
|
That'd break compat with EventEmitter though. I had wondered if |
|
Renaming :) list -> l, type -> t |
|
@loopmode that's currently done via Uglify as a build step - the 200b size cap we're tracking is actually on the ES3 output. |
|
@developit Doesn't seem like compat is that important, is it? node's |
|
True, I always forget that. I was using WildEmitter prior to writing this, which has |
|
@mjackson yea, but it is well-known convention and it feels more natural than returning unsubs from |
|
I've done both and would love to support both if we can squeeze it in. The bind technique should make it pretty cheap 👍 |
|
I've tried different implementation to reduce size of final lib, but no luck, I'm getting 38 bites more. |
|
Here's a technique for manually creating an unsubscribe function. let e = mitt();
function handler() {}
e.on('foo', handler);
let unsub = e.off.bind(e, 'foo', handler); |
|
I think I found a way, opening a PR. |
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
Forked from developit#1.
|
closing in favor of #42 |
It will be good if on() function returns unsubscribe function