@@ -64,24 +64,24 @@ public struct StateMachineSchema<A, B, C>: StateMachineSchemaType {
6464/// block. It is called after a transition with three arguments:
6565/// the state before the transition, the event causing the transition,
6666/// and the state after the transition.
67- public final class StateMachine < T : StateMachineSchemaType > {
67+ public final class StateMachine < Schema : StateMachineSchemaType > {
6868 /// The current state of the machine.
69- public private( set) var state : T . State
69+ public private( set) var state : Schema . State
7070
7171 /// An optional block called after a transition with three arguments:
7272 /// the state before the transition, the event causing the transition,
7373 /// and the state after the transition.
74- public var didTransitionCallback : ( ( T . State , T . Event , T . State ) -> ( ) ) ?
74+ public var didTransitionCallback : ( ( Schema . State , Schema . Event , Schema . State ) -> ( ) ) ?
7575
7676 /// The schema of the state machine. See `StateMachineSchemaType`
7777 /// documentation for more information.
78- private let schema : T
78+ private let schema : Schema
7979
8080 /// Object associated with the state machine. Can be accessed in
8181 /// transition blocks. Closure used to allow for weak references.
82- private let subject : ( ) -> T . Subject ?
82+ private let subject : ( ) -> Schema . Subject ?
8383
84- private init ( schema: T , subject: ( ) -> T . Subject ? ) {
84+ private init ( schema: Schema , subject: ( ) -> Schema . Subject ? ) {
8585 self . state = schema. initialState
8686 self . schema = schema
8787 self . subject = subject
@@ -92,7 +92,7 @@ public final class StateMachine<T: StateMachineSchemaType> {
9292 /// becomes `nil`. If the transition logic of the schema defines a transition
9393 /// for current state and given event, the state is changed, the optional
9494 /// transition block is executed, and `didTransitionCallback` is called.
95- public func handleEvent( event: T . Event ) {
95+ public func handleEvent( event: Schema . Event ) {
9696 guard let
9797 subject = subject ( ) ,
9898 ( newState, transition) = schema. transitionLogic ( state, event)
@@ -109,18 +109,18 @@ public final class StateMachine<T: StateMachineSchemaType> {
109109}
110110
111111
112- public extension StateMachine where T . Subject: AnyObject {
112+ public extension StateMachine where Schema . Subject: AnyObject {
113113 /// Creates a state machine with a weak reference to a subject. This helps
114114 /// to remove subject-machine reference cycles, but it also means you have
115115 /// to keep a strong reference to a subject somewhere else. When subject
116116 /// reference becomes `nil`, transitions are no longer performed.
117- public convenience init ( schema: T , subject: T . Subject ) {
117+ public convenience init ( schema: Schema , subject: Schema . Subject ) {
118118 self . init ( schema: schema, subject: { [ weak subject] in subject } )
119119 }
120120}
121121
122122public extension StateMachine {
123- public convenience init ( schema: T , subject: T . Subject ) {
123+ public convenience init ( schema: Schema , subject: Schema . Subject ) {
124124 self . init ( schema: schema, subject: { subject } )
125125 }
126126}
0 commit comments