Skip to content

Commit 2cb66b8

Browse files
committed
project: improve readme
1 parent d7674e3 commit 2cb66b8

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ func deinit() {
327327

328328
## Extras
329329

330-
### Conditionally resumable `send()` function
331-
330+
<details>
331+
<summary>Conditionally resumable `send()` function</summary>
332332
Allows to send an event while awaiting for a specific state or set of states to resume.
333333

334334
```swift
@@ -337,9 +337,10 @@ await viewStateMachine.send(
337337
resumeWhen: .closed
338338
)`
339339
```
340+
</details>
340341

341-
### Side effect cancellation
342-
342+
<details>
343+
<summary>Side effect cancellation</summary>
343344
Make `close(speed:)` side effect execution be cancelled when the state machine produces any new states. It is also possible to cancel on a specific state.
344345

345346
```swift
@@ -349,26 +350,28 @@ Runtime.map(
349350
strategy: .cancelWhenAnyState
350351
)
351352
```
353+
</details>
352354

353-
### States set
354-
355+
<details>
356+
<summary>States set</summary>
355357
Allows to factorize the same transition for a set of states.
356358

357359
```swift
358360
When(states: OneOf {
359-
State.closing(persons:),
360-
State.closed
361+
State.closing(persons:),
362+
State.closed
361363
}) { _ in
362-
Execute.noOutput
364+
Execute.noOutput
363365
} transitions: {
364-
On(event: Event.closeButtonWasPressed) { _ in
365-
Transition(to: State.opening)
366-
}
367-
}`
366+
On(event: Event.closeButtonWasPressed) { _ in
367+
Transition(to: State.opening)
368+
}
369+
}`
368370
```
371+
</details>
369372

370-
### SwiftUI bindings
371-
373+
<details>
374+
<summary>SwiftUI bindings</summary>
372375
Allows to create a SwiftUI binding on the current state, sending an Event when the binding changes.
373376

374377
```swift
@@ -380,9 +383,10 @@ Allows to create a SwiftUI binding on a property of the current state, sending a
380383
```swift
381384
self.viewStateMachine.binding(keypath: \.persons, send: .closeButtonWasPressed)
382385
```
386+
</details>
383387

384-
### Connecting two state machines
385-
388+
<details>
389+
<summary>Connecting two state machines</summary>
386390
This will send the event `OtherEvent.refresh` in the other state machine when the first state machine's state is `State.closed`.
387391

388392
```swift
@@ -391,9 +395,10 @@ let channel = Channel<OtherEvent>()
391395
let runtime = Runtime<State, Event, Output>()
392396
...
393397
.connectAsSender(to: channel, when: State.closed, send: OtherEvent.refresh)
394-
395-
398+
399+
396400
let otherRuntime = Runtime<OtherState, OtherEvent, OtherOutput>()
397401
...
398402
.connectAsReceiver(to: channel)
399403
```
404+
</details>

0 commit comments

Comments
 (0)