https://kotlinlang.org logo
#coroutines
Title
# coroutines
j

João Eudes Lima

01/21/2021, 4:18 AM
When using MutableLiveData works
g

gildor

01/21/2021, 4:24 AM
could you show some code example
j

João Eudes Lima

01/21/2021, 5:01 AM
message has been deleted
this
copy()
is unnecessary there, but to show
In mode debug i see alert in collect of method fetchCurrentUser(), but donot emit
g

gildor

01/21/2021, 5:13 AM
Let’s start from beginning, your original question mentioned live data, but it looks that not whole code is here
It’s hard to say what you expect and where it broken
I also don’t see MutableStateFlow
it’s not really related to you problem, but overal approach looks incorrect for me, why use shared mutable state (MutableLiveData/MutableStateFlow) to expose this state insted just mapping to original flow?
j

João Eudes Lima

01/21/2021, 6:05 AM
Sorry
g

gildor

01/21/2021, 6:12 AM
are you sure that you call fetchCurrentUser?
have you tried to debug it (just print logs what is called)
j

João Eudes Lima

01/21/2021, 6:16 AM
I'm debugged via breakpoints, in collect enter, but in "emit" of asLivedata no (i'm copy the code of this function to test)
Yeah, the fetchCurrentUser is called
g

gildor

01/21/2021, 6:17 AM
ah, with breakpoints it can be quite tricky
so what is your result?
j

João Eudes Lima

01/21/2021, 6:24 AM
message has been deleted
Debug via print there
is emitted more often because getCurrentUser is used elsewhere
message has been deleted
value of mutableStateFlow is detected as equal to new value (it), but is not equal, the value of property
nome
is
jsnsn
because the
emit
is not called
@gildor understood the problem that is occurring?
g

gildor

01/21/2021, 7:03 AM
value and it have the same hashcode, so looks as incorrect equals/hashcode implementation, if some values insdide are different
also in debug but has the same value in
nome
as I see on screenshot
try to print $it in collected in fetchjCurrentUser log
but according to debug those have the same content (at least from what I see on screenshot)
j

João Eudes Lima

01/21/2021, 7:49 AM
Yeah, but this update of value is not emitted
g

gildor

01/21/2021, 7:54 AM
but does value is actually different?
because on your screenshot it’s the same
j

João Eudes Lima

01/21/2021, 1:03 PM
The problem is on the change of data, i'm are changing with apply the coming from .value 🤦🏻‍♂️
Thanks @gildor
👍 1