Skip to content

Commit b42ac6d

Browse files
committed
Update README.md
1 parent c1c18ec commit b42ac6d

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ If there is no `Event`-based transition, use built-in `NoEvent` instead.
100100

101101
### State & Event enums with associated values
102102

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 either of the following functions to apply _closure-style routing_:
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 either of the following functions to apply _closure-style routing_:
104104

105105
- `machine.addRouteMapping(routeMapping)`
106-
- `RouteMapping`: `(event: E?, fromState: S, userInfo: Any?) -> S?`
106+
- `RouteMapping`: `(event: E?, fromState: S, userInfo: Any?) -> S?`
107107
- `machine.addStateRouteMapping(stateRouteMapping)`
108-
- `StateRouteMapping`: `(fromState: S, userInfo: Any?) -> [S]?`
109-
- This is a synonym for multiple routing e.g. `.State0 => [.State1, .State2]`
108+
- `StateRouteMapping`: `(fromState: S, userInfo: Any?) -> [S]?`
110109

111110
For example:
112111

@@ -175,17 +174,21 @@ For more examples, please see XCTest cases.
175174

176175
- Easy Swift syntax
177176
- Transition: `.State0 => .State1`, `[.State0, .State1] => .State2`
178-
- Try transition: `machine <- .State1`
179-
- Try transition + messaging: `machine <- (.State1, "GoGoGo")`
177+
- Try state: `machine <- .State1`
178+
- Try state + messaging: `machine <- (.State1, "GoGoGo")`
180179
- Try event: `machine <-! .Event1`
181180
- Highly flexible transition routing
182181
- Using `Condition`
183-
- Using `.Any` state/event
184-
- Blacklisting: `.Any => .Any` + `Condition`
182+
- Using `.Any` state
183+
- Entry handling: `.Any => .SomeState`
184+
- Exit handling: `.SomeState => .Any`
185+
- Blacklisting: `.Any => .Any` + `Condition`
186+
- Using `.Any` event
187+
185188
- Route Mapping (closure-based routing): [#36](https://github.com/ReactKit/SwiftState/pull/36)
186-
- Success/Error/Entry/Exit handlers with `order: UInt8` (more flexible than before/after handlers)
187-
- Removable routes and handlers
188-
- Chaining: `.State0 => .State1 => .State2`
189+
- Success/Error handlers with `order: UInt8` (more flexible than before/after handlers)
190+
- Removable routes and handlers using `Disposable`
191+
- Route Chaining: `.State0 => .State1 => .State2`
189192
- Hierarchical State Machine: [#10](https://github.com/ReactKit/SwiftState/pull/10)
190193

191194
## Terms
@@ -198,8 +201,8 @@ State Machine | `Machine` | State transition manager which c
198201
Transition | `Transition` | `From-` and `to-` states represented as `.State1 => .State2`. Also, `.Any` can be used to represent _any state_.
199202
Route | `Route` | `Transition` + `Condition`.
200203
Condition | `Context -> Bool` | Closure for validating transition. If condition returns `false`, transition will fail and associated handlers will not be invoked.
201-
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.
202-
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.
204+
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.
205+
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` (synonym for multiple routing e.g. `.State0 => [.State1, .State2]`). See [#36](https://github.com/ReactKit/SwiftState/pull/36) for more info.
203206
Handler | `Context -> Void` | Transition callback invoked when state has been changed successfully.
204207
Context | `(event: E?, fromState: S, toState: S, userInfo: Any?)` | Closure argument for `Condition` & `Handler`.
205208
Chain | `TransitionChain` / `RouteChain` | Group of continuous routes represented as `.State1 => .State2 => .State3`

0 commit comments

Comments
 (0)