brabo-hi
07/25/2023, 3:01 AM@Composable
fun MyComponent(uiState: MyUiState, firstName: String, lastName: String) {
Column {
Text(text = uiState.data)
TextField(value = firstName, onValueChange = {})
TextField(value = lastName, onValueChange = {})
}
}
Where MyUiState
is represented into the viewmodel as StateFlow
firstName
and lastName
as State
used both in TextField.
Is it a good practice to add firstName
and lastName
into the StateFlow MyUiStateFlow
?Christiano
07/25/2023, 6:34 AMuiState
should contain everything that the UI will show.
Also working with events, makes it a lot easier to manage and update the state in the viewmodel.brabo-hi
07/25/2023, 7:02 AMChristiano
07/25/2023, 7:09 AMdewildte
07/25/2023, 5:14 PMColton Idle
07/25/2023, 9:33 PMStylianos Gakis
07/26/2023, 10:44 AMColton Idle
07/26/2023, 1:22 PMColton Idle
07/26/2023, 1:22 PMclass MyVM(appState: AppStateHolder): ViewModel(){
val screenState = ScreenState()
fun doX(){
scope.launch{
val result = doNetworkCallOrSomething
screenState.foo = result.mapToDomainOrUiLayer
}
}
}
Colton Idle
07/26/2023, 1:23 PMdewildte
07/26/2023, 3:15 PMdewildte
07/26/2023, 3:15 PMChristiano
07/26/2023, 3:17 PMColton Idle
07/26/2023, 3:31 PMdewildte
07/26/2023, 3:32 PMdewildte
07/26/2023, 3:32 PMdewildte
07/26/2023, 3:38 PMColton Idle
07/26/2023, 3:39 PMdewildte
07/26/2023, 3:40 PMdewildte
07/26/2023, 3:41 PMdewildte
07/26/2023, 3:41 PMdorche
07/26/2023, 4:34 PMColton Idle
07/26/2023, 6:15 PM