android / architecture-samples

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
Apache License 2.0
44.32k stars 11.62k forks source link

UDF experiment for producing state by merging flows #862

Closed tunjid closed 2 years ago

tunjid commented 2 years ago

Produces state by merging flows that carry functions that lazily modify the state.

This avoids the issues that can arise when combining flows:

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. This one of the reasons for adding Turbine as a test dependency.