Pablo
03/05/2025, 11:33 AMstateHolder.doExtraLogic()
?
We do that with viewmodels ( vm.doExtraLogic()
), but I'm not sure if that is a good practice also with composable state holders. I want this composable to be very portable. I mean that moving it to another project is simply to copy and paste the .kt file and using it, so will be a benefit to have that extra logic functions in the state holder. Is it a good practice to do this?Zach Klippenstein (he/him) [MOD]
03/05/2025, 5:54 PMZach Klippenstein (he/him) [MOD]
03/05/2025, 5:54 PMPablo
03/05/2025, 7:10 PMPablo
03/05/2025, 7:15 PMArne Jans
03/06/2025, 11:20 AM@Composable
fun Dialog(
sendEmail: (String) -> Boolean,
shareStuff: () -> Unit,
...
): {
...
Button(onClick = { sendEmail(text) }, ...)
...
}
That way you would be able to reuse that Composable more easily, and for tests, specify those lambdas as empty lambdas, with maybe a Boolean set to true.
Also, this enables `@Preview`s of the Composable, just pass empty lambdas in there.Zach Klippenstein (he/him) [MOD]
03/06/2025, 4:00 PM