How to update a mutablestate uistate to set current selected item in a viewmodel? I have this uistate class, and need to change selectedBookId value.
sealed interface BooksGridUiState {
data class Success(
val booksList: List<BookData>,
val selectedBookId: String?
) : BooksGridUiState
object Error : BooksGridUiState
object Loading : BooksGridUiState
}
This is the variable in the viewmodel:
val uiState: BooksGridUiState by mutableStateOf(BooksGridUiState.Loading)
private set
Can’t do the trick of calling
.update {
it.copy(
Because this is not a mutablestateflow, and I’m following a codelab and must use mutablestate (editado)