-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor code for better typing, naming, and RouteMapping support. #36
Conversation
Please ping me for any thoughts on this 😉 |
Cool! FrogcjnTest.swift#L124-L180 this is just what I needs. Thanks! |
@frogcjn Thanks! I need to improve tests too, so it may take a bit more time to finish this up. So please let me get this right ;) |
…hine`. - Add `Machine` (event-only-driven state machine). - Add `Disposable` derived from ReactiveCocoa. - Add Package.swift & change directory structure for Swift-Package-Manager.
I applied a 2nd big refactor in f7ce748 to add following features:
There are now 2 machine classes, |
See also (strict directory structure): swiftlang/swift-package-manager#16 |
Ref: swift-package-manager + SwiftState 4.0.0-RC (e9c1bf3) build failure in Ubuntu 14.04 |
Hey, we don't want to force anyone to have a directory structure they don't want. We will add configurability to the |
@mxcl |
Create universal framework to support watchOS & tvOS by using xcconfigs.
Ready to |
Refactor code for better typing, naming, and RouteMapping support.
🎉🎉🎉 |
This is a BREAKING CHANGE and release candidate for next version 4.0.0,
greatly improved typing and
RouteMapping
support (handling states/events with associated values).See Also: #34
Simple Class Names
I renamed many verbose class names e.g.
StateTransition
to simpleTransition
.(Even if the name collides with other frameworks, we can just simply add framework-prefix e.g.
SwiftState.Transition
to avoid it.)Better Typing
As requested in #34 by @frogcjn, current version 3.x needs to use
StateType
/EventType
which conforms toNilLiteralConvertible
to represent.Any
state/event, but it was quite ugly because we needed to add extracase Any
in their enums.To alleviate this, I added extra enum wrappers (
State<S>
&Event<E>
) so that users no longer need to implement.Any
anymore.RouteMapping
RouteMapping
andStateRouteMapping
are new ways of adding routes which has a closure typeto navigate StateMachine to preferred
toState
without using traditional arrow style, e.g.fromState => toState
.These closures help resolving states & events with associated values.
Please see
FrogcjnTest.swift#L124-L180RouteMappingTests.swift#L77-L133 for more details.Simple
Machine
class (works like Redux)StateMachine
(which cantryState()
as well astryEvent()
) is now a subclass of simpler classMachine
which is capable oftryEvent()
only.By splitting these codes, along with
RouteMapping
,Machine
will now behave like rackt/redux in JavaScript, a safe state container.For more information on Redux, see http://redux.js.org/ .
Easy Disposable of routes & handlers
There were previously
RouteID
andHandlerID
being passed as return value for asking StateMachine to unregister, but nowDisposable
(derived from ReactiveCocoa) will take care of it.Others