Zoltan Demant
01/19/2023, 3:16 PMModifier.graphicsLayer { alpha = state.value }
in order to reduce the recomposition scope. I feel like that doesnt matter when using a Modifier? Example in 🧵!Zoltan Demant
01/19/2023, 3:18 PMprivate fun Modifier.visibility(
visible: Boolean
): Modifier {
return composed {
val alphaState = animateFloatAsState(
target = if (visible) 1f else 0f
)
graphicsLayer {
alpha = alphaState.value
}
}
}
I might as well do this?
val alphaState by animateFloatAsState(
target = if (visible) 1f else 0f
)
Because the recomposition scope doesnt change if I "delay" the read. Am I understanding that right?Zoltan Demant
01/19/2023, 3:18 PMby
thing inside the Modifier.composed block 🙂robercoding
01/19/2023, 3:25 PMby
, the alphaState
will still be read where it's used, so in this case inside graphicsLayer
So in this case it doesn't matter, you're "still deferring the read", so all good 👍robercoding
01/19/2023, 3:26 PMAlbert Chang
01/20/2023, 2:19 AM=
and by
is completely the same in terms of recomposition scope.