eygraber
01/19/2024, 6:25 PMcollectAsState
. When that state updates, it means that something else (that isn't directly observable or a state) updated as well, and I want to use that in a composable. What's the better approach (aside from refactoring to get away from this issue):
val current by foo.updates.collectAsState()
val bar by remember(current) { foo.bar }
or
val current by foo.updates.collectAsState()
val bar by remember {
derivedStateOf {
current // just to get the update
foo.bar
}
}
eygraber
01/19/2024, 6:27 PMremember(current)
in the first one because it doesn't seem like the whole scope recomposes when current
updates; only the scopes where current
is actually read.Ian Lake
01/19/2024, 6:46 PMproduceState
? https://developer.android.com/jetpack/compose/side-effects#producestate
val bar by produceState(initialValue = foo.bar, foo) {
foo.updates.collect {
value = foo.bar
}
}
Ian Lake
01/19/2024, 6:48 PMproduceState
under the hoodeygraber
01/19/2024, 6:48 PMcurrent
further down the composable?Ian Lake
01/19/2024, 6:49 PM