S.
04/13/2022, 9:19 PMLazyColumn and a corresponding add function in the viewmodel but no matter what I try the list does not refresh itself.
basically the same code is used for a search feature which works fine. only difference it's not called from a onClick but from onValueChangedS.
04/13/2022, 9:20 PMval decks by viewModel.decks.collectAsState()
ViewModel
private val _decks = MutableStateFlow(Client.userDecks.value)
val decks: StateFlow<List<Deck>> = _decks
suspend fun addDeck(deck: NewDeck) {
Client.addDeck(deck)
_decks.value = Client.userDecks.value
}
suspend fun filterDecks(input: String) {
_decks.value = Client.userDecks.value.filter { bla bla }
}S.
04/13/2022, 9:22 PM_decks.value and it does contain the added value. forcing the list to recompose by switching screens etc also shows the new valueAlbert Chang
04/14/2022, 12:49 AMClient.userDecks?S.
04/14/2022, 12:51 AMStateFlow<List<Deck>> , Deck being a custom data classAlbert Chang
04/14/2022, 12:52 AMClient.addDeck() do?S.
04/14/2022, 12:56 AMS.
04/14/2022, 12:57 AMMutableStateFlow of it. just checkedS.
04/14/2022, 12:57 AMprivate val myDecks = MutableStateFlow<MutableList<Deck>>(mutableListOf())
val userDecks: StateFlow<List<Deck>> = myDecksAlbert Chang
04/14/2022, 12:58 AMS.
04/14/2022, 12:59 AMS.
04/14/2022, 1:01 AMMichael Paus
04/14/2022, 9:28 AMval decks: StateFlow<List<Deck>> = _decks
should more correctly be
val decks: StateFlow<List<Deck>> = _decks.asStateFlow()S.
04/14/2022, 11:01 AMasStateFlow() be the same as writing the type explicitly?Mitchell Syer
04/14/2022, 2:20 PM