What different performance when uiState
init with collectAsState
and use by
or =
?
val uiState by viewModel.uiState.collectAsState()
vs
val uiState = viewModel.uiState.collectAsState()
What different performance when uiState
init with collectAsState
and use by
or =
?
val uiState by viewModel.uiState.collectAsState()
vs
val uiState = viewModel.uiState.collectAsState()
Copyright © 2021 Jogjafile Inc.
It basically allows you to save using the getter in order to read the value of your state, check the example below.
In your view model you can have the state like this
and then in your view if you use the by operator it allows you to read directly the state without the ".value"
In case you use "=" then you would need to the getter ("state.value") to access the value.