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
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ enum MyEvent: EventType {
74
74
let machine = StateMachine<MyState, MyEvent>(state: .State0) { machine in
75
75
76
76
// add 0 => 1 => 2
77
-
machine.addRouteEvent(.Event0, transitions: [
77
+
machine.addRoute(event: .Event0, transitions: [
78
78
.State0=> .State1,
79
79
.State1=> .State2,
80
80
])
@@ -89,9 +89,8 @@ machine <-! .Event0
89
89
XCTAssertEqual(machine.state, MyState.State2)
90
90
91
91
// tryEvent
92
-
let success = machine <-! .Event0
93
-
XCTAssertEqual(machine.state, MyState.State2)
94
-
XCTAssertFalse(success, "Event0 doesn't have 2 => Any")
92
+
machine <-! .Event0
93
+
XCTAssertEqual(machine.state, MyState.State2, "Event0 doesn't have 2 => Any")
95
94
```
96
95
97
96
If there is no `Event`-based transition, use built-in `NoEvent` instead.
@@ -126,8 +125,9 @@ State Machine | `Machine` | State transition manager which c
126
125
Transition | `Transition` | `From-` and `to-` states represented as `.State1 => .State2`. Also, `.Any` can be used to represent _any state_.
127
126
Route | `Route` | `Transition` + `Condition`.
128
127
Condition | `Context -> Bool` | Closure for validating transition. If condition returns `false`, transition will fail and associated handlers will not be invoked.
129
-
Route Mapping | `(event: E?, fromState: S, userInfo: Any?) -> S?` | Another way of defining routes **using closure instead of transition arrows (`=>`)**. This is useful when state & event are enum with associated values. Return value (`S?`) means "preferred-toState", where passing `nil` means no routes available. See [#36](https://github.com/ReactKit/SwiftState/pull/36) for more info.
130
-
Handler | `Context -> Void` | Transition callback invoked after state has been changed.
128
+
Event Route Mapping | `(event: E?, fromState: S, userInfo: Any?) -> S?` | Another way of defining routes **using closure instead of transition arrows (`=>`)**. This is useful when state & event are enum with associated values. Return value (`S?`) means preferred-`toState`, where passing `nil` means no routes available. See [#36](https://github.com/ReactKit/SwiftState/pull/36) for more info.
129
+
State Route Mapping | `(fromState: S, userInfo: Any?) -> [S]?` | Another way of defining routes **using closure instead of transition arrows (`=>`)**. This is useful when state is enum with associated values. Return value (`[S]?`) means multiple `toState`s from single `fromState`. See [#36](https://github.com/ReactKit/SwiftState/pull/36) for more info.
130
+
Handler | `Context -> Void` | Transition callback invoked when state has been changed successfully.
0 commit comments