Where to hoist that state in Compose? 了解在 Jetpack Compose 中提升状态的方式和场景。
1. Composable functions
点击 Message 展示消息时间。


Not hoisting is a valid option.
这个 UI 逻辑例子不需要提升状态。
2. State hoisting
在下面的例子中,消息列表的状态需要提升。






Place state in the lowest common ancestor.
3. Plain state holder class
使用 state holder class 做状态提升,例如 LazyListState。 
LazyListState 抽象了 scrollPosition 同时暴露了应用逻辑的方法,比如 scrollToItem()、scroll()、animateScrollToItem()。
4. Android architecture Components(AAC)ViewModel
使用 ViewModel 做状态提升。



5. Recap

