Comments (6)
In your example, you are registering event-based routes but attaching state-based handler, so it doesn't react to any event-triggering.
To fix this, please replace:
// register handler for state-based transition, e.g. `machine <- .State0`
machine.addHandler(.Any => .Any) { ... }
to:
// register handler for event-based transition, e.g. `machine <-! .Event0`
machine.addHandler(event: .Event0) { ... }
from swiftstate.
I thought it was working in previous version, though ?
from swiftstate.
Yes, previous ver 3.x was working in that way (equal to addEventHandler()
).
From ver 4.0.0, you need to use machine.addHandler(event:)
instead.
P.S.
For reacting to any events, you can use machine.addHandler(event: .Any)
.
from swiftstate.
Updated README.md in 84d4b42.
from swiftstate.
π
I see that. Thanks !
from swiftstate.
Hello.
I find this behavior surprising. I was just playing with SwiftState, and wanted to model the state machine using a mix of events and states. The idea being that I would attach handlers to the states, but send events to the machine to transition.
I understand this is not possibleβI would have to choose events or states, but not both.
from swiftstate.
Related Issues (20)
- Example in Readme lacks MyEvent. HOT 3
- Allow Swift 2.0 code to be used by CocoaPods HOT 1
- Whats meaning of nil => .State2 ? Got an error HOT 2
- Can't use event handler by itself HOT 9
- Can't build with Swift 2.0 on XCode7 beta5 HOT 5
- suggestion on transition and condition, which should include Event HOT 10
- Request for improvement HOT 2
- SwiftLint config error on carthage build HOT 2
- iOS 7 support HOT 4
- Swift 3.0 compatible? HOT 7
- Arrow pointing the wrong direction for sending events? HOT 2
- onEntry and onExit handlers? HOT 3
- Swift 4.0 compatible? HOT 2
- Carthage Build failed with exit code 65 HOT 3
- CocoaPod doens't compile with Xcode 9.2 HOT 1
- Would be really helpful if you version it better with each commit to master or swift/4.0
- Version 4.1.0 - doesnt compile HOT 3
- How to use with a Vapor3 project HOT 1
- State & Event enums with associated values complete example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftstate.