arnis71
08/31/2020, 4:01 PMStateFlow
. The problem is that this lambda gets called on some other thread so I have to freeze it. But when I freeze it the data objects also gets frozen and in turn it freezes the StateFlow
and then it crashes with mutability exception.
Is it even possible to do what I described with current KN memory model? Any help would be appreciated, thanks!mbonnin
08/31/2020, 4:04 PMarnis71
08/31/2020, 4:24 PMmbonnin
08/31/2020, 4:27 PMmbonnin
08/31/2020, 4:27 PMStateFlow
?arnis71
08/31/2020, 4:31 PMkpgalligan
09/01/2020, 2:35 PMmbonnin
09/01/2020, 2:39 PMkpgalligan
09/01/2020, 2:42 PMkpgalligan
09/01/2020, 2:42 PM@Test
fun failLocal(){
val d = Dat("Hello")
assertFails {
DetachedObjectGraph {d}
}
}
data class Dat(val s:String)
kpgalligan
09/01/2020, 2:42 PMkpgalligan
09/01/2020, 2:43 PMkpgalligan
09/01/2020, 2:44 PMmbonnin
09/01/2020, 2:45 PMkpgalligan
09/01/2020, 2:46 PMkpgalligan
09/01/2020, 2:47 PMkpgalligan
09/01/2020, 2:47 PMarnis71
11/09/2020, 4:51 AMDetachedObjectGraph
is very wasteful.
My issue was that i want to get something from the background thread and then post the value to the StateFlow
that was created in the UI thread. Right now it fails with freezing exception. I’ve managed to find a workaround to use ConflatedBroadcastChannel
which somehow works in this situation. But i wonder is it somehow possible to do this with StateFlow
or am I approaching this issue from the wrong angle?