ninadmg
05/16/2022, 11:41 AM```* [graphicsLayer] can be used to apply effects to content, such as scaling, rotation, opacity,
* shadow, and clipping.
* Prefer this version when you have layer properties backed by a
* [androidx.compose.runtime.State] or an animated value as reading a state inside [block] will
* only cause the layer properties update without triggering recomposition and relayout.```This is the documentation of graphics layer. From this it looks like i can make changes to the graphics layer without recomposing the parent composable. But how to I collect a state in the graphics layer as it is not a composable? If i collect a state in the parents then it will recompose the parent.
Filip Wiesner
05/16/2022, 11:44 AMBut how to I collect a state in the graphics layer as it is not a composable?You don't need to be in Composable context to read snapshot state
ninadmg
05/16/2022, 11:48 AM.collectAsState()
somewhere. The Composable
in which i collect at state will recompose when the state changes right? Even if i use it or not?Filip Wiesner
05/16/2022, 11:52 AMkotlinx.coroutines.flow.Flow
API but the documentation talks about androidx.compose.runtime.State
.The collectAsState()
is transformation between these two APIs.
And I think it should not matter where you make this transformation. What matters is where you read the resulting state.Theis not true.in which i collect at state will recompose when the state changes.Composable
ninadmg
05/16/2022, 11:56 AM