Hello all. Back to working on my project after a b...
# tornadofx
s
Hello all. Back to working on my project after a break and have been thinking about TornadoFX's type safe css. Coming from a web dev background, I've always done my CSS in this way:
Copy code
menu, menuButton, otherThing { some styles }
where I would apply a specific set of styles to multiple css classes just by adding them to the list before the style declaration. As far as I can tell, the only way to achieve something like this in Kotlin would be to make a function that would loop through every css element argument and apply the styles to each one. Is there a reason TornadoFX's type safe css doesn't allow this sort of functionality (Kotlin coding conventions I would assume, but maybe there is a different reason? For safety, or something), or are there plans to add something like this in the future? I would be interested in hearing any sort of arguments against this sort of thing, as well! God knows there are thousands of code safety hazards in web development.
a
I think it's all about how builders are implemented on type level. The thing is called lambda with receiver and works as some kind of extension function for that specific instance of the type. You may simulate such behavior with some workaround, like Introducing custom builder that takes other builders as arguments and applies it's body to each argument.