Grégory Lureau
06/13/2022, 9:48 PM@Composable
fun testMolecule(): Int {
var value by remember { mutableStateOf(0) }
LaunchedEffect(Unit) {
value += 1
}
return value
}
val coroutineScope = rememberCoroutineScope()
val lastValue = coroutineScope.launchMolecule {
testMolecule()
}
println("lastValue=${lastValue.value}")
-> print "lastValue=0" on every frame. With this code I'm expecting value to be 1 and no recomposition.james
06/13/2022, 10:30 PMjossiwolf
06/13/2022, 10:38 PMlaunchMolecule
? That looks like you're calling it in a Composable?Grégory Lureau
06/14/2022, 6:50 AMtestMolecule()
function in a class (VM) and call it from the view to have my state. Is it forbidden?