Replies: 1 comment 1 reply
-
Your suggestion would capture a subset of use cases. Bear in mind that you can handle events emitted from children or other sources, and handlers may handle events from multiple sources. It's also complicated by the fact that widgets can be far more dynamic than your example. There may be an arbitrary number of buttons depending on your input. I'm not unsympathetic to wanting to making things play nice with static analysis, but UIs tend to be too dynamic to fully capture that way. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
I am new to the library, so I might have missed something that solves this issue for me. I apologize if I missed something obvious.
Problem
While the title is a bit pretentious and maybe not even completely feasible, I feel it would be good to build an API that doesn't communicate through "magic" for hooking up event handlers and other plumbing.
You can fix that with attributes, but it's clunky.
There are also other similar issues like automatic message handler naming.
Possible solution
I propose a
child()
function. It allows the attributes to be defined in the class body so you have access to it there similar to@property
and@[property_name].setter
.It also allows easy access to nested events.
Other Notes
I know that a lot of the API has been built to model web development (hence the blatant borrowing of CSS, event bubbling, etc.), but vanilla js web development has its issues which is part of why so many web frameworks exist. I think magic values make small projects easy to quickly develop, but makes it much harder to maintain in the future
One can argue the form of CSS that is present is also a "bag of magic", but I am unable to think of a solution without a cruddy css-in-js equivalent.
Beta Was this translation helpful? Give feedback.
All reactions