-
Notifications
You must be signed in to change notification settings - Fork 127
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
Implement a managed API for bind, on, after and every #107
Comments
I like a) for being concise and to the point, but also b) for being more clear. In favor of b), it might introduce new possibilities as well, e.g. Also, since option a) doesn't have a way to unbind, we could return a callback function that unbinds, e.g.: var change = on('screensDidChange', function () {});
change(); // unbind This pattern at least used to be pretty common in JS, not sure about where it stands today. PS. Hyvää juhannusta! 😄 🎉 |
@mafredri Kiitos, sitä samaa! |
This has been now implemented and will be released in 2.1.2. I hope the new API is more consistent than the previous examples. This should also be a more familiar concept for new users. 😄 Key.on('q', [ 'ctrl', 'shift' ], function () {});
Key.off(identifier);
Event.on('screensDidChange', function () {});
Event.off(identifier);
Timer.after(1, function () {});
Timer.every(1, function () {});
Timer.off(identifier); |
Nice effort! :) |
It seems that those users who don’t want to dynamically control handlers seem to get confused for the requirement to retain handlers. Lets abstract this in the JavaScript scope. Implement a managed API for
bind
,on
,after
andevery
.a.) Implement them to the global scope:
b.) Create a prettier API with counter actions:
This will not change or break existing behaviour and advanced contexts can and should still manually manage handlers. We should also change all examples to use the managed API.
The text was updated successfully, but these errors were encountered: