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
.events
emits, isLoading
stays false.isLoading = true
is rundata
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.isLoading
and then passing it as a key to the effect.efemoney
02/03/2023, 11:09 PM