Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Check with gradle
run: ./gradlew runUnitTests :examples:lce:assembleDebug :examples:welcome:welcome:assembleDebug :examples:multi:navbar:assembleDebug :examples:multi:parallel:assembleDebug :examples:lifecycle:assembleDebug --no-daemon --no-configuration-cache
run: ./gradlew runUnitTests :examples:lce:assembleDebug :examples:welcome:welcome:assembleDebug :examples:multi:navbar:assembleDebug :examples:multi:parallel:assembleDebug :examples:lifecycle:assembleDebug :examples:di:app:assembleDebug :examples:book:app:assembleDebug :examples:book:book:demo:assembleDebug --no-daemon --no-configuration-cache
- name: Upload problems report
uses: actions/upload-artifact@v4
if: failure()
Expand Down
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/artifacts
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/copilot
/.idea/*.xd
/.idea
.DS_Store
/build
/.kotlin
Expand Down
6 changes: 0 additions & 6 deletions .idea/AndroidProjectSystem.xml

This file was deleted.

40 changes: 0 additions & 40 deletions .idea/appInsightsSettings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/copyright/Apache.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/deploymentTargetSelector.xml

This file was deleted.

37 changes: 0 additions & 37 deletions .idea/gradle.xml

This file was deleted.

32 changes: 0 additions & 32 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/migrations.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

17 changes: 0 additions & 17 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/studiobot.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

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

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

#### Common child flow API

For your convenience there are couple of ready-made interfaces to adopt child flow.
The interfaces are located in a separate libraries:

```groovy
dependencies {
// If you use it for state machines only
implementation "com.motorro.commonstatemachine:commonflow-data:x.x.x"
// If you go with compose
implementation "com.motorro.commonstatemachine:commonflow-compose:x.x.x"
}
```

The libraries include the following interfaces:

- [CommonFlowHost](commonflow/data/src/commonMain/kotlin/com/motorro/commonstatemachine/flow/data/CommonFlowHost.kt) -
the interface the proxy should provide to the child flow. Child uses this flow to signal its termination.
- [CommonFlowDataApi](commonflow/data/src/commonMain/kotlin/com/motorro/commonstatemachine/flow/data/CommonFlowDataApi.kt) -
contains methods to initiate the flow and to adapt it to the hosting flow.
- [CommonFlowUiApi](commonflow/compose/src/commonMain/kotlin/com/motorro/commonstatemachine/flow/compose/CommonFlowUiApi.kt) -
An interface with the single `Screen` method to inject and put to the composition

For more details on multiplatform compose viewmodel follow [this link](https://kotlinlang.org/docs/multiplatform/compose-viewmodel.html)

Check the [example](examples/di) that shows the use of this flow:

- The app has two states: `Content` and `Auth`.
- `Content` requires authenticated user.
- We have a basic [authentication flow](examples/di/api) flow defined.
- We have two implementation modules [Login](examples/di/login) and [Social](examples/di/social) that authenticate users
using different authentication "providers".
- The [app](examples/di/app) module has two build variants to support each.
- The concrete sub-flow is provided with the late DI binding using `Hilt`


## Running state-machines in parallel (composition)

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