-
Notifications
You must be signed in to change notification settings - Fork 438
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
Design problem #146
Comments
Why can't you give your arrow function a name?
|
I see what you saying, I do need to remove them at some point. So instead of relying on .on returning fn. I can take them from your loop. thanks. |
Just to close this out: wildcard event listeners do receive the emitter.on('*', (type, val) => {
console.log(type, val); // ["updated_foo", "bar"]
});
emitter.emit('updated_foo', 'bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a bit of "design" problem that makes this not usable.
Real life example: I have several fields i need to get events from. Do not want to use .all in this case.
for (let i = 0; i < fields.length; i++)
emitter.on('updated_' + fields[i], ReCalculate);
function ReCalculate(val) {
..do not know which field was undated. Only have it's new value
}
The issue could have been easily solved with arrow function but then i can never remove it.
Also just have .on method return fn it got as a parameter. That way i can unsubscribe arrow functions as well.
The text was updated successfully, but these errors were encountered: