architecture-samples icon indicating copy to clipboard operation
architecture-samples copied to clipboard

MVVM+ branch

Open tunjid opened this issue 1 year ago • 0 comments

Produces state by using a StateProducer that merges flows that carry functions that lazily modify the state.

This avoids the issues that can arise when combining flows:

  • The limited arity of the combine function
  • The difficulty of merging the effects of user actions into the state production pipeline
  • There are a probably a few rough edges, but it has an element of consistency across all ViewModels.

This change has the interesting side effect of only being able to push state changes only if there is an observer of UI state. If there is no observer of state, all pending pushes will suspend until an observer is present.

It also means and coroutines launched have to honor the SharingStarted passed to the StateProducer. This means both Flows and suspend functions in ViewModels only run as specified by WhileUiSubscribed which is SharingStarted.WhileSubscribed(5_000).

It also lets users just setState.

tunjid avatar Aug 24 '22 15:08 tunjid