-
Notifications
You must be signed in to change notification settings - Fork 22
State Flow and Shared Flow
Devrath edited this page Jan 21, 2024
·
5 revisions
- Flows are mostly cold but
state-flow
andshared-flow
are exceptions here - The
St.Flow
andSh.Flow
exist independently of collectors. This means that these flows remain active even if there are no collectors. -
State Flow
is a special case ofshared flow
.
- This is a flow that acts independently of collectors - Meaning the
share flow
is active regardless of whether there are any collectors or not. - Shared flow emits a
current state
andnew state
to the subscribers. -
Shared-flow
never completes and remains active. Even though all the subscribers go away, TheShared Flow
remains active.
- State Flow is a version of Shared Flow.
- It has a single immutable value.
- It emits current and new states to the subscribers.
- It never completes
- It has a value property and we can retrieve the current value by using that value property.
- It acts as a data holder and observable
-
LiveData
is bound to the UI and the Android but theStateFlow
isplatform independent
.