tezvyn:

How would you architect two source Flows from ViewModel to data layer?

Source: developer.android.comadvanced

This tests merging parallel async streams into one reactive state. A strong answer uses combine on two cold repository Flows, exposes one UI state Flow from the ViewModel, and maps failures to error states. Red flag: using two coroutines mutating shared state.

This tests composing independent network sources into a single reactive pipeline with error boundaries. A great answer hits four things: first, two cold repository Flows fetching independently; second, a ViewModel using combine to merge them into one UI state holding data, loading and error fields; third, flowOn or distinctUntilChanged to avoid redundant work; fourth, catch mapping to typed errors. Red flag: launching two viewModelScope coroutines that post into a MutableStateFlow which loses backpressure and creates race conditions.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

How would you architect two source Flows from ViewModel to data layer? · Tezvyn