In jetpack compose api guidelines, under hoisted s...
# compose
s
In jetpack compose api guidelines, under hoisted state types (https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md#hoisted-state-types It says that it is best to provide
VerticalScrollerState
instead of
Copy code
scrollPosition: Int,
scrollRange: Int,
onScrollPositionChange: (Int) -> Unit,
onScrollRangeChange: (Int) -> Unit
The issue I am experiencing with this approach is that now I can not update my viewModel when
"onSomethingHappened"
. I tried adding a callback to my custom state object but it just did not feel right. Is there a suggestion/best practice about how I can observe changes to my custom state object (and each of the parameters in it)?
a
If the source of truth lives in your viewmodel, your implementation of the state interface can delegate to that viewmodel