Re:Userinterface.js – A small library to build front-end Jav...
by thoughtsunifica on Monday June 01, 2020 @06:30PM
(#23384792)
The helper function is one hell of a great idea. I like it.
I get your point, and it's a fair one. Right now if you want to "prepend" you have to add a container as first child and give it a className to identify it and then use the "runModel" on it.
I like the idea of going the opposite way and I also share your thoughts about component only caring for its own state.
Thank you (again) very much for your feedback, much appreciated.
The majority of what I see being painful to use here is caused by exposing all of that manual boilerplate. You can do something equivalent with a hyperscript-like syntax:
Or with JSX that compiles down to what you have in your `properties`: You could even trivially add a helper function with low runtime costs that makes it easier to write out the properties. Just using `h` here since it's like hyperscript, but you could call it something better: That alone would make it easer to read and write properties. The example would become: There are other things that you can't fix with syntax changes, though. For example, each model defining the `method` used to add it to the parent seems backwards to me. Shouldn't a component only care about its own state? Down the road, if you wanted to add one of these `children` things to another element by prepending it rather than appending it, you'd have to have to change the child.