Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for the website #523

Merged
merged 34 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2b7922a
Update docs for condition block (replace inStateWithCndition)
sockeqwe Jun 19, 2023
363589e
Update condition description
sockeqwe Jun 19, 2023
e2d8b37
smaller improvements
sockeqwe Jun 19, 2023
bee8753
Merge branch 'main' into update_docs
sockeqwe Jul 25, 2023
a229c0b
Split DSL docs into subsections and added untilIdentityChanged example
sockeqwe Jul 26, 2023
56bfa5b
Merge branch 'main' into update_docs
sockeqwe Jul 26, 2023
6a74aa9
more explanation to untilIdentityChanged
sockeqwe Jul 26, 2023
acd805b
more explanation to untilIdentityChanged
sockeqwe Jul 26, 2023
50a7709
Merge branch 'main' into update_docs
sockeqwe Jul 26, 2023
9b773d9
Filled out the DSL Cheatsheet
sockeqwe Jul 26, 2023
fa3c300
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
5137557
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
ef9f66b
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
7c4a012
Update docs/user-guide/onEnter.md
sockeqwe Jul 27, 2023
04f34fc
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
e237228
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
d0701e1
Update docs/user-guide/onAction.md
sockeqwe Jul 27, 2023
f748809
Update docs/user-guide/inState.md
sockeqwe Jul 27, 2023
4a1822b
Update docs/user-guide/ExecutionPolicy.md
sockeqwe Jul 27, 2023
6ee637c
Update docs/dsl-cheatsheet.md
sockeqwe Jul 27, 2023
a96ec74
navigation
sockeqwe Jul 27, 2023
2744ee3
Merge branch 'update_docs' of https://github.com/freeletics/FlowRedux…
sockeqwe Jul 27, 2023
ff78665
fixing path
sockeqwe Jul 27, 2023
37b5f6a
Use error message in docs instaed of Throwable
sockeqwe Jul 27, 2023
6650f89
suspending instead of blocking
sockeqwe Jul 27, 2023
8b96bc0
playing around with nav
sockeqwe Jul 27, 2023
c53f27b
Merge branch 'main' into update_docs
sockeqwe Jul 27, 2023
2514bc3
cleanup and set correct year for copyright
sockeqwe Jul 27, 2023
5738eea
Merge branch 'update_docs' of https://github.com/freeletics/FlowRedux…
sockeqwe Jul 27, 2023
2c4cd09
removed accidentally changed things
sockeqwe Jul 27, 2023
65f996f
Updated the DSL cheatsheet
sockeqwe Jul 28, 2023
e3db4c5
Moved Multiplatform section into README.md and is therefore part of t…
sockeqwe Jul 28, 2023
1f6ae71
Cleanup menu
sockeqwe Jul 28, 2023
4fc2fe6
Styling
sockeqwe Jul 28, 2023
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
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,17 @@ implementation 'com.freeletics.flowredux:compose:<latest-version>'
implementation 'com.freeletics.flowredux:flowredux:<latest-version>'
```

### JavaScript
No javascript version released yet but it is on our roadmap.
FlowRedux is supported on:

- JVM / Android
- iOS
- watchOS
- tvOS
- macOS
- Linux
- Windows

We do plan to add support for JavaScript but it’s not available yet.

### Snapshot
Latest snapshot (directly published from `main` branch from CI on each change):
Expand All @@ -134,5 +143,5 @@ allprojects {
Then just use `-SNAPSHOT`suffix as version name like

```groovy
implementation 'com.freeletics.flowredux:flowredux:1.0.3-SNAPSHOT'
implementation 'com.freeletics.flowredux:flowredux:1.1.1-SNAPSHOT'
```
3 changes: 2 additions & 1 deletion docs/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ fun SearchBoxUi(searchQuery : String, dispatchAction: (AddressBookAction) -> Uni
Column {
TextField(
value = searchQuery,
onValueChange = { text -> dispatchAction(SearchQueryChangedAction(text)) } // dispatches action async to state machine
// dispatches action async to state machine
onValueChange = { text -> dispatchAction(SearchQueryChangedAction(text)) }
)
}
}
Expand Down
96 changes: 96 additions & 0 deletions docs/dsl-cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
hide:
- navigation
- toc
---

# DSL Cheatsheet

If you want to learn more about a particular part of the DSL, we recommend taking a look at the [user guide](/user-guide/).

The following section describes the syntax and usage of the DSL blocks:

```kotlin
spec {
inState<State1>{ // inState is always a "top level" element

// Handle external "input", called Actions
on<Action1>{ action, state -> ... } // Handle an action
on<Action2>(ExecutionPolicy){ action, state -> ... } // You can have multiple on<Action> blocks. Optionally specify ExecutionPolicy

// Do something when you enter the state.
onEnter{ state -> ... } // Called exactly one time when the given state has been entered
onEnter{ state -> ... } // You can have multiple onEnter blocks

// Collect a Flow (from kotlinx.coroutines) as long as the state machine is in the state (see inState<State>)
collectWhileInstate(flow1) { valueEmitedFromFlow, state -> ... } // stops flow collection when state is left
collectWhileInstate(flow2) { valueEmitedFromFlow, state -> ... } // You can have multiple collectWhileInstate

// Effects to do something without changing the state (i.e. logging, analytics, ...)
onActionEffect<Action1>{ action, state -> ... } // You can have multiple onActionEffect
onEnterEffect{ state -> ... } // You can have multiple onEnterEffect
collectWhileInStateEffect(flow1){ valueEmitedFromFlow, state -> ... } // You can have multiple collectWhileInstate

// Hierarchical state machines
onEnterStartStateMachine(
stateMachineFactory = { stateSnapshot : State1 -> OtherStateMachine() },
stateMapper = { state : State<State1>, otherStateMachineState : OtherState -> ... }
)
onActionStartStateMachine<Action1>(
stateMachineFactory = { action, stateSnapshot : State1 -> OtherStateMachine() },
stateMapper = { state : State<State1>, otherStateMachineState :OtherState -> ... }
)
onEnterStartStateMachine(...) // You can have multiple onEnterStartStateMachine
onActionStartStateMachine(...) // You can have multiple onActionStartStateMachine

unitlIdentityChanged({ state.id }) {
// Everyhting inside this block executes only as long as the "identity" (in this example state.id)
// doesn't change. When it changes, then the previous executions will be canceled and
// this block starts again but with the changed state

// you can have multiple of the dsl blocks, i.e. multiple on<Action> blocks and so on.
on<Action3>{ action, state -> ... } // you can have multiple on<Action>
onEnter{ state -> ... }
collectWhileInState(flow){ valueEmitedFromFlow, state -> ... }
onActionEffect{ action, state -> ...}
onEnterEffect{ state -> ... }
collectWhileInStateEffect(flow){ valueEmitedFromFlow, state -> ... }
onEnterStartStateMachine(...)
onActionStartStateMachine(...)
}

// Custom conditions
condition({ state.someString == "Hello" }){
// Everything inside this block only executes if the surounding condition is met
// and the state machine is in the state as specified by the top level inState<State1>.

// You can have each DSL block multiple times, i.e. multiple on<Action> blocks and so on.
on<Action3>{ action, state -> ... }
onEnter{ state -> ... }
collectWhileInState(flow){ valueEmitedFromFlow, state -> ... }
onActionEffect{ action, state -> ...}
onEnterEffect{ state -> ... }
collectWhileInStateEffect(flow){ valueEmitedFromFlow, state -> ... }
onEnterStartStateMachine(...)
onActionStartStateMachine(...)

untilIdentityChanged(...) { // version of untilIdentityChanged that is only ran if the condition block is active
on<Action3>{ action, state -> ... }
onEnter{ state -> ... }
collectWhileInState(flow){ valueEmitedFromFlow, state -> ... }
onActionEffect{ action, state -> ...}
onEnterEffect{ state -> ... }
collectWhileInStateEffect(flow){ valueEmitedFromFlow, state -> ... }
onEnterStartStateMachine(...)
onActionStartStateMachine(...)

// Please note that you cannot have a condition block inside an untilIdentityChanged block
}

// Please note that you cannot have nested conditions inside a condition block
}
}

inState<State2> { ... } // You can have multiple "top level" inState blocks
}
```
Loading