https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
d

dewildte

04/10/2019, 7:12 PM
The use case in my mind would be to ensure the UI receives all it's states upon starting so I can do animations, or am I cray cray?
g

gildor

04/11/2019, 6:41 AM
Could you explain what do you mean?
In general I would avoid mixing LiveData with Flow, same way I would avoid to do that with Channels or Observables, I really don’t see good use cases except adapters to work with some existing component
m

Melih Aksoy

04/11/2019, 8:29 AM
LiveData’s
postValue
does not guarantee that you’ll receive every emitted value
g

gildor

04/11/2019, 8:50 AM
The same with ConflatedBroadcastChannel (which is most probably should be used as adapter for LiveData)
d

dewildte

04/11/2019, 1:50 PM
Yes, agreed.
You don't have to use
postValue
, you can launch a main thread coroutine and use
setValue
.
m

Melih Aksoy

04/11/2019, 2:54 PM
You can do that indeed, but remember switching context comes with a cost too, also will make getting results back blocking. Using a standard channel for example, would be much more suitable compared to LiveData
d

dewildte

04/11/2019, 5:34 PM
The cost is a fine price to pay if you are using something like MVI. The boundary is crossed only when setting the entire UI's state.
Depends on the app I guess but I have not noticed any problems.
Modern phones are so damn powerful anyway.
a

Ahmed Adel

04/14/2019, 8:41 AM
d

dewildte

04/14/2019, 11:29 PM
@Ahmed Adel Thanks but I am purposely trying to avoid RxJava
a

alexsullivan114

04/15/2019, 7:51 PM
I'm interested in this - I have no experience with
Flow
, so forgive me if I'm missing the point. Is the question about whether it makes sense to use both
LiveData
and
Flow
in a single app?
g

gildor

04/16/2019, 12:29 AM
Yes, correct
d

dewildte

04/16/2019, 2:40 AM
Correct
a

alexsullivan114

04/16/2019, 12:02 PM
I use RxJava and LiveData in a single app, which feels like a similar question
I've found the benefits to be easy testability (since LiveDatas API is so trivial) and reduced possibility for scope creep on my view objects. I've actually come to really love the simplicity that LiveData brings in the View <> Presenter/ViewModel layer.
4 Views