This is a sample Android app to demonstrate the use-case of Flow, and LiveData together. Previously, I was using Coroutines along with LiveData, but it was time to upgrade myself.
Regarding Flow, a Flow
is a type that can emit multiple values sequentially, as opposed to suspending functions that return only a single value. Flow
is basically a COLD stream which means that it is on-demand and will emit the data when being observed or collected (collect()
). On the other hand, Hot Flow
s as SharedFlow
and StateFlow
act differently. They are always ACTIVE regardless of being observed or not! More info: StateFlow and SharedFlow
MVVM architecture | Hilt-dagger, LiveData, Flow, Retrofit, RecyclerView, DataBinding, Glide