How can i call a @Composable function from reflect...
# compose
t
How can i call a @Composable function from reflection. I know that the compiler plugin will add two additional parameters to the function. The question is what should i provide in this first two parameters. One needs the Composer and the second an Int (I think it is the slot). Is it possible to do this via reflection?
z
i don’t think this is officially supported, but I remember Leland saying that the int parameter was designed so it would be reasonable to pass 0 to initially, or something like that. So then you just need the composer. There’s some code in the preview infra that you might look for calls to in the rest of the codebase: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ewUtils.kt;l=166;drc=6867aa1d8441dd83fc3c06c2e135c4d11e5228f6
a
it's a bitfield that communicates parameter stability and comparison propagation
z
right, so passing zero every time should technically work, it just won’t get any of the optimizations, right?
a
yeah, iirc
getting some docs about the abi of this into an official location is on the todo list
t
@Zach Klippenstein (he/him) [MOD] Thank you very much for this link. Exactly what i need. I will try it later.