Spencer
02/16/2023, 9:08 PMCacheAndNetwork from emitting 2 values when the cache value and network value are the same?Stylianos Gakis
02/16/2023, 9:14 PM.distinctUntilChanged on the flow itself. Don’t know if there’s something that can be done on the apollo-kotlin side though for this, or if something should be done there.Spencer
02/17/2023, 4:28 PM.distinctUntilChanged { prev, current ->
prev.data?.equals(current.data)
}
it was always coming up falseStylianos Gakis
02/17/2023, 4:47 PMequals method returns false for them. So either
• They are not actually the same
• Their equals method is somehow broken
Have you checked why this returns false? Have you debugged and made sure those two objects are in fact the exact same data? Try something like that and if it still doesn’t work we can maybe figure out what’s going wrong.
Also as a side note, where are you applying this distinctUntilChanged? Showing some more code may help in case there’s some small mistake somewhereSpencer
02/17/2023, 4:51 PMprev.data.toString() == current.data.toString() makes it return true then.
apolloClient.query(query)
.fetchPolicy(CacheAndNetwork)
.watch()
.distinctUntilChanged { prev, current ->
prev.data.toString() == current.data.toString()
}
.collect { response ->
//....
}
}.catch {
//....
}Spencer
02/17/2023, 4:53 PMStylianos Gakis
02/17/2023, 4:53 PMfalse I suppose right? Even though their toStrings() return true.
This may mean that their toString() is not really printing out everything, and that thing which is not printed out is different between them.
Other than that, I can’t imagine how else this could be failing. Remind me, are those generated classes all data classes, or do they have their equals methods manually generated somehow?Spencer
02/17/2023, 5:01 PMSpencer
02/17/2023, 5:09 PMStylianos Gakis
02/17/2023, 5:53 PMStylianos Gakis
02/17/2023, 5:55 PMSpencer
02/17/2023, 5:59 PMSpencer
02/17/2023, 9:20 PMStylianos Gakis
02/17/2023, 10:43 PMequals yourself properly instead of converting it into a data class if you don’t need that.
But so glad to help you, very happy that it now works 🎉