@@ -26,17 +26,11 @@ public class StateMachineRouteID<S: StateType, E: StateEventType>
2626 self . transition = transition
2727 self . routeKey = routeKey
2828 self . event = event
29-
30- self . bundledRouteIDs = nil
3129 }
3230
3331 private init ( bundledRouteIDs: [ StateMachineRouteID < S , E > ] ? )
3432 {
3533 self . bundledRouteIDs = bundledRouteIDs
36-
37- self . transition = nil
38- self . routeKey = nil
39- self . event = nil
4034 }
4135}
4236
@@ -54,16 +48,11 @@ public class StateMachineHandlerID<S: StateType, E: StateEventType>
5448 {
5549 self . transition = transition
5650 self . handlerKey = handlerKey
57-
58- self . bundledHandlerIDs = nil
5951 }
6052
6153 private init ( bundledHandlerIDs: [ StateMachineHandlerID < S , E > ] ? )
6254 {
6355 self . bundledHandlerIDs = bundledHandlerIDs
64-
65- self . transition = nil
66- self . handlerKey = nil
6756 }
6857}
6958
@@ -350,6 +339,11 @@ public class StateMachine<S: StateType, E: StateEventType>
350339 return self . addRoute ( route)
351340 }
352341
342+ public func addRoute( transition: Transition , condition: @autoclosure ( ) -> Bool ) -> RouteID
343+ {
344+ return self . addRoute ( transition, condition: { t in condition ( ) } )
345+ }
346+
353347 public func addRoute( route: Route ) -> RouteID
354348 {
355349 return self . _addRoute ( route)
@@ -395,6 +389,11 @@ public class StateMachine<S: StateType, E: StateEventType>
395389 return self . addRoute ( route, handler: handler)
396390 }
397391
392+ public func addRoute( transition: Transition , condition: @autoclosure ( ) -> Bool , handler: Handler ) -> ( RouteID , HandlerID )
393+ {
394+ return self . addRoute ( transition, condition: { t in condition ( ) } , handler: handler)
395+ }
396+
398397 public func addRoute( route: Route , handler: Handler ) -> ( RouteID , HandlerID )
399398 {
400399 let transition = route. transition
@@ -622,6 +621,11 @@ public class StateMachine<S: StateType, E: StateEventType>
622621 return self . addRouteChain ( routeChain, handler: handler)
623622 }
624623
624+ public func addRouteChain( chain: TransitionChain , condition: @autoclosure ( ) -> Bool , handler: Handler ) -> ( RouteID , HandlerID )
625+ {
626+ return self . addRouteChain ( chain, condition: { t in condition ( ) } , handler: handler)
627+ }
628+
625629 public func addRouteChain( chain: RouteChain , handler: Handler ) -> ( RouteID , HandlerID )
626630 {
627631 var routeIDs : [ RouteID ] = [ ]
@@ -783,6 +787,11 @@ public class StateMachine<S: StateType, E: StateEventType>
783787 return self . addRouteEvent ( event, routes: routes)
784788 }
785789
790+ public func addRouteEvent( event: Event , transitions: [ Transition ] , condition: @autoclosure ( ) -> Bool ) -> [ RouteID ]
791+ {
792+ return self . addRouteEvent ( event, transitions: transitions, condition: { t in condition ( ) } )
793+ }
794+
786795 public func addRouteEvent( event: Event , routes: [ Route ] ) -> [ RouteID ]
787796 {
788797 var routeIDs : [ RouteID ] = [ ]
@@ -809,6 +818,11 @@ public class StateMachine<S: StateType, E: StateEventType>
809818
810819 return ( routeIDs, handlerID)
811820 }
821+
822+ public func addRouteEvent( event: Event , transitions: [ Transition ] , condition: @autoclosure ( ) -> Bool , handler: Handler ) -> ( [ RouteID ] , HandlerID )
823+ {
824+ return self . addRouteEvent ( event, transitions: transitions, condition: { t in condition ( ) } , handler: handler)
825+ }
812826
813827 public func addRouteEvent( event: Event , routes: [ Route ] , handler: Handler ) -> ( [ RouteID ] , HandlerID )
814828 {
0 commit comments