Open dtaskoff opened 5 years ago
Just to reiterate the note leohaskell made about custom events: if something like that were implemented, there would still need to be some way to listen to events with arbitrary string names:
DOM events are not limited to a specific set -- "synthetic" events can be created and used that have any string name: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events
Specifically, I believe it's not uncommon to make use of synthetic events when building custom elements: https://developers.google.com/web/fundamentals/web-components/customelements
Another solution to this problem would be to provide more functions like ‘onClick’, ‘onInput’, and the like, which is a viable option, as well, although it’s not as flexible as the above mentioned solution, because the user will have to stick with the provided specific implementations.
Currently, Html.Events.on has the following type signature:
Several times, I've been struggling to find what I'm doing wrong, only to discover, that I've mistyped the event's name (stringly-typed ftw).
Wouldn't it be better, to replace that
String
argument with an enum, which has all current javascript events, plus aCustom String
one, for custom events? If you're up for such a change, I'm willing to implement it.