You can use either in terms of achieving the same functionality. I originally began with LiveData, than refactored the Repositories to Flow, and now am using mostly Flow.

I outlined the Model-View-Intent (MVI) pattern with Flow in Android Model-View-Intent with Kotlin Flow.

The preference I have for Flow in the ViewModel layer is it reduces the complexity of the MVI pattern. Complexity may vary depending on the specific architecture pattern used.

Additional complexity remains due to the need for a mutable and immutable view state class. Again, because LiveData is bound to a view’s lifecycle, a mutable view state cannot be initiated and observed in the ViewModel as with Flow or RxJava Subjects. As a workaround, the mutable view state adds values in the ViewModel, and the immutable view state is observed directly by the view instead of being emitted in the ViewModel through an interface contract like withFeedView.

--

--

--

Open Sourcer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Hurwitz

Adam Hurwitz

Open Sourcer

More from Medium

Security in Android 12 — For Developers

Get Started with RxKotlin

Simple Android Network Traffic Inspection With Chucker And Seismic

Worms Eye View From Spiral colored decore glass through a roof

Common Gotchas in Android’s Share Sheet