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
Use `<-!` operator to try transition by `Event` rather than specifying target `State` ([Test Case](https://github.com/ReactKit/SwiftState/blob/6858f8f49087c4b8b30bd980cfc81e8e74205718/SwiftStateTests/StateMachineEventTests.swift#L54-L76)).
62
+
63
+
```swift
64
+
let machine = StateMachine<MyState, MyEvent>(state: .State0) { machine in
65
+
66
+
// add 0 => 1 => 2
67
+
machine.addRouteEvent(.Event0, transitions: [
68
+
.State0=> .State1,
69
+
.State1=> .State2,
70
+
])
71
+
}
72
+
73
+
// tryEvent
74
+
machine <-! .Event0
75
+
XCTAssertEqual(machine.state, MyState.State1)
76
+
77
+
// tryEvent
78
+
machine <-! .Event0
79
+
XCTAssertEqual(machine.state, MyState.State2)
80
+
81
+
// tryEvent
82
+
let success = machine <-! .Event0
83
+
XCTAssertEqual(machine.state, MyState.State2)
84
+
XCTAssertFalse(success, "Event0 doesn't have 2 => Any")
0 commit comments