android-compose-mvvm-foodies icon indicating copy to clipboard operation
android-compose-mvvm-foodies copied to clipboard

hi,please tell me this

Open yuexunshi opened this issue 2 years ago • 0 comments

BaseViewModel: private val _viewState: MutableState<UiState> = mutableStateOf(initialState) val viewState: State<UiState> = _viewState

@Composable private fun FoodApp() { val viewModel: FoodCategoriesViewModel = viewModel() val state = viewModel.viewState.value

Any changes to value will schedule recomposition of any composable functions that read value. In the case of ExpandingCard, whenever expanded changes, it causes ExpandingCard to be recomposed.

here dont hava remember,why it can to be recomposed?

i think it is : val state by remember{ viewModel.viewState.value }

but no remember,it can be recomposed.

yuexunshi avatar Jun 02 '22 07:06 yuexunshi