0001 // 0002 // State.swift 0003 // Transporter 0004 // 0005 // Created by Denys Telezhkin on 06.07.14. 0006 // Copyright (c) 2014 Denys Telezhkin. All rights reserved. 0007 // 0008 // Permission is hereby granted, free of charge, to any person obtaining a copy 0009 // of this software and associated documentation files (the "Software"), to deal 0010 // in the Software without restriction, including without limitation the rights 0011 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0012 // copies of the Software, and to permit persons to whom the Software is 0013 // furnished to do so, subject to the following conditions: 0014 // 0015 // The above copyright notice and this permission notice shall be included in 0016 // all copies or substantial portions of the Software. 0017 // 0018 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0019 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0020 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0021 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0022 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0023 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 0024 // THE SOFTWARE. 0025 0026 /** 0027 `State` class encapsulates state with some value, and closure-based callbacks to fire when state machine enters or exits state. 0028 */ 0029 public class State<T
Event.swift:47 case Success(sourceState: State<T>, destinationState: State<T>)Event.swift:47 case Success(sourceState: State<T>, destinationState: State<T>)State.swift:35 public var willEnterState: ( (enteringState : State<T> ) -> Void)?State.swift:38 public var didEnterState: ( (enteringState : State<T> ) -> Void)?State.swift:41 public var willExitState: ( (exitingState : State<T> ) -> Void)?State.swift:44 public var didExitState: ( (exitingState : State<T> ) -> Void)?StateMachine.swift:63 var initialState: State<T>StateMachine.swift:66 public private(set) var currentState : State<T>StateMachine.swift:69 private lazy var availableStates : [State<T>] = []StateMachine.swift:76 required public init(initialState: State<T>)StateMachine.swift:87 self.init(initialState:State(initialStateValue))StateMachine.swift:94 convenience public init(initialState: State<T>, states: [State<T>])StateMachine.swift:94 convenience public init(initialState: State<T>, states: [State<T>])StateMachine.swift:133 public func addState(state: State<T>) {StateMachine.swift:139 public func addStates(states: [State<T>]) {StateMachine.swift:236 return Transition.Success(sourceState: currentState, destinationState: State(event.destinationValue))StateMachine.swift:247 public func stateWithValue(value: T) -> State<T>? {:Hashable> { 0030 0031 /// Value of state 0032 public let value
State.swift:32 public let value : TState.swift:35 public var willEnterState: ( (enteringState : State<T> ) -> Void)?State.swift:38 public var didEnterState: ( (enteringState : State<T> ) -> Void)?State.swift:41 public var willExitState: ( (exitingState : State<T> ) -> Void)?State.swift:44 public var didExitState: ( (exitingState : State<T> ) -> Void)?State.swift:48 public init(_ value: T) {: T 0033 0034 /// Closure, that will be executed, before state machine enters this state 0035 public var willEnterState
State.swift:49 self.value = valueStateMachine.swift:123 return element.value == stateValueStateMachine.swift:235 if event.sourceValues.contains(currentState.value) {StateMachine.swift:249 return element.value == valueStateMachine.swift:266 return stateValue == currentState.value: ( (enteringState : State<T> ) -> Void)? 0036 0037 /// Closure, that will be executed, after state machine enters this state 0038 public var didEnterState
StateMachine.swift:109 newState.willEnterState?(enteringState: newState): ( (enteringState : State<T> ) -> Void)? 0039 0040 /// Closure, that will be executed before state machine will switch from current state to another state. 0041 public var willExitState
StateMachine.swift:115 newState.didEnterState?(enteringState: currentState): ( (exitingState : State<T> ) -> Void)? 0042 0043 /// Closure, that will be executed after state machine switched from current state to another state. 0044 public var didExitState
StateMachine.swift:110 oldState.willExitState?(exitingState: oldState): ( (exitingState : State<T> ) -> Void)? 0045 0046 /// Create state with value 0047 /// - Parameter value: value of state 0048 public init
StateMachine.swift:114 oldState.didExitState?(exitingState: oldState)(_ value: T) { 0049 self.value = value 0050 } 0051 } 0052
StateMachine.swift:87 self.init(initialState:State(initialStateValue))StateMachine.swift:236 return Transition.Success(sourceState: currentState, destinationState: State(event.destinationValue))