Adam Hurwitz
1 min readJul 21, 2020

--

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.

  • 🏞️ May 2019 — Unidirectional Data Flow (UDF) with LiveData
  • 🍂 Nov. 2019 — UDF w/ LiveData + Flow
  • 🏖️ July 2020 — MVI + UDF with 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.

--

--

Adam Hurwitz

An account about nothing | Researcher and product consultant