Skip to content

Commit 0349dcd

Browse files
committed
Common flow host and API documentation
Refs: #11
1 parent 0a2e765 commit 0349dcd

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

.idea/markdown.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Please checkout the Medium article on pattern/library usage.
4040
+ [Gestures and view-states](#gestures-and-view-states)
4141
+ [View implementation](#view-implementation)
4242
+ [Adopting foreign state-flow](#adopting-foreign-state-flow)
43+
+ [Common flow API](#common-child-flow-api)
4344
- [Running state-machines in parallel (composition)](#running-state-machines-in-parallel-composition)
4445
* [MultiMachineState](#multimachinestate)
4546
* [ProxyMachineContainer](#proxymachinecontainer)
@@ -135,6 +136,7 @@ val commonMain by getting {
135136
- [Navbar](examples/multi/navbar) - several machines running in proxy state, one of them active at a time
136137
- [Mixed](examples/multi/mixed) - two machines of different gesture/UI system mixed in one state
137138
- [Lifecycle](examples/lifecycle) - track your Android app lifecycle to pause pending operations when the app is suspended
139+
- [DI](examples/di) - late child flow binding, allows for a dynamic module ([read more](#common-child-flow-api))
138140
- [Contacts](https://github.com/Android-Developer-Basic/Contacts) - more or less real world KMP/CMP application with network and database
139141

140142
## The basic task - Load-Content-Error
@@ -1174,6 +1176,28 @@ or to advance to `Complete` state as described in [Common Api](#common-api). The
11741176
this interface by switching host machine to email or complete states in corresponding
11751177
`backToEmailEntry` and `complete` functions.
11761178

1179+
#### Common child flow API
1180+
1181+
For your convenience there are couple of ready-made interfaces to adopt child flow.
1182+
They are:
1183+
1184+
- [CommonFlowHost](commonstatemachine/src/commonMain/kotlin/com/motorro/commonstatemachine/flow/CommonFlowHost.kt) -
1185+
the interface the proxy should provide to the child flow. Child uses this flow to terminate but could
1186+
also include any other callbacks
1187+
- [CommonFlowDataApi](commonstatemachine/src/commonMain/kotlin/com/motorro/commonstatemachine/flow/CommonFlowApi.kt) -
1188+
contains methods to initiate the flow and to adapt it to the hosting flow.
1189+
1190+
Check the [example](examples/di) that shows the use of this flow:
1191+
1192+
- The app has two states: `Content` and `Auth`.
1193+
- `Content` requires authenticated user.
1194+
- We have a basic [authentication flow](examples/di/api) flow defined.
1195+
- We have two implementation modules [Login](examples/di/login) and [Social](examples/di/social) that authenticate users
1196+
using different authentication "providers".
1197+
- The [app](examples/di/app) module has two build variants to support each.
1198+
- The concrete sub-flow is provided with the late DI binding using `Hilt`
1199+
1200+
11771201
## Running state-machines in parallel (composition)
11781202

11791203
In case you want several state-machines to run in parallel producing a single combined UI state or you

0 commit comments

Comments
 (0)