You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-3Lines changed: 74 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ Any => 2, msg=Optional("Hello")
62
62
63
63
### Transition by Event
64
64
65
-
Use `<-!` operator to try transition by `Event` rather than specifying target `State` ([Test Case](https://github.com/ReactKit/SwiftState/blob/1be67826b3cc9187dfaac85c2e70613f3129fad6/SwiftStateTests/TryEventTests.swift#L32-L54)).
65
+
Use `<-!` operator to try transition by `Event` rather than specifying target `State`.
66
66
67
67
```swift
68
68
enumMyEvent: EventType {
@@ -79,7 +79,10 @@ let machine = StateMachine<MyState, MyEvent>(state: .State0) { machine in
XCTAssertEqual(machine.state, MyState.State2, "Event0 doesn't have 2 => Any")
94
97
```
95
98
96
99
If there is no `Event`-based transition, use built-in `NoEvent` instead.
97
100
101
+
### State & Event enums with associated values
102
+
103
+
Above examples use _arrow-style routing_ which are easy to understand, but it lacks in ability to handle state & event enums with associated values. In such cases, use `machine.addRouteMapping()` and pass either of the following closure types (_closure-style routing_):
This behaves very similar to JavaScript's safe state-container [rackt/Redux](https://github.com/rackt/redux), where `EventRouteMapping` can be interpretted as `Redux.Reducer`.
0 commit comments