Fabio Berta
02/03/2023, 1:19 PMvar isLoading by remember(data) { mutableStateOf(false) }
LaunchedEffect(events) {
events.collect {
isLoading = true
}
}
The idea is that I have a local isLoading
state that I want to set to true when events
emits something. I want to reset it to false, when data
changes. This works perfectly the first time events
emits. isLoading
goes to true
and when updated data
comes in, it goes back to false
.Fabio Berta
02/03/2023, 1:19 PMevents
emits, isLoading
stays false.Fabio Berta
02/03/2023, 1:20 PMisLoading = true
is runFabio Berta
02/03/2023, 1:20 PMFabio Berta
02/03/2023, 1:53 PMdata
changes, a new mutableStateOf
is created but the LaunchedEffect
is not keyed on it. Hence what happens when events
emit is that it changes the previous mutable state which no one is listening to anymore.Fabio Berta
02/03/2023, 2:27 PMisLoading
and then passing it as a key to the effect.Fabio Berta
02/03/2023, 2:27 PMefemoney
02/03/2023, 11:09 PM