https://kotlinlang.org logo
#compose
Title
# compose
r

romainguy

05/25/2019, 7:27 AM
Something like:
fun ValidateTextField(foo: Bar, @ParamsOf<TextField> p)
e

elizarov

05/25/2019, 7:33 AM
There've been also various ideas floating in Kotlin on how this might be solved in general case. One I'm personally a fan of: https://youtrack.jetbrains.com/issue/KT-15471
👍 11
c

Chuck Jazdzewski [G]

05/25/2019, 6:05 PM
It would be nice to also be able to turn a functions parameters into a
dataargs
capable type using some operator such as
ParamsOf
as alluded to by Romain. This fits nicely with
dataargs
allowing
CustomButton
, from the proposal, to be written without
Button
having to be modified ahead of time.
e

elizarov

05/25/2019, 6:58 PM
It raises the problem of separate compilation, then. It may or may not be important, but a factor to consider.
Hm... just a thought. If a target function opts-in into reuse of its parameter lists, then it may be made to work with separate compilation.
c

Chuck Jazdzewski [G]

05/28/2019, 4:17 PM
Good point. We would need a way to have separate compilations be able to share the class implied by
ParamsOf
. For native this should be easy, such as using a COMDEF record or equivalent, but for the JVM is would be more challenging.
e

elizarov

05/28/2019, 4:23 PM
One solution is to always generate a hidden “params class” for every composable function and always pass params though this class, which would make the process of sharing parameters completely transparent for end-users, yet it will also always add some overhead.
c

Chuck Jazdzewski [G]

05/28/2019, 11:02 PM
That was my intent if we implement it as part of
@Composable
. The number of hidden classes explode, however, if it is general language feature.
2 Views