Skip to content

Commit

Permalink
Reimplement eventWithName method to make changes backwards compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTelezhkin committed Mar 13, 2018
1 parent 4368dfc commit c436428
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sources/StateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,22 @@ open class StateMachine<T:Hashable> {
}.first
}

/// Retrieve event with specific name
/// Retrieve events with specific name
/// - Parameter name: Name of the event
/// - Returns: event, if found.
/// - Returns: events with specified name, if found.
open func eventsWithName(_ name: String) -> [Event<T>] {
return events.filter { (element) -> Bool in
return events.filter { element in
return element.name == name
}
}

/// Retrieve event with specific name
/// - Parameter name: Name of the event
/// - Returns: event, if found.
open func eventWithName(_ name: String) -> Event<T>? {
return eventsWithName(name).first
}

/// Check, whether state machine is in concrete state
/// - Parameter stateValue: value of state to check for
/// - Returns: whether state machine is in this state.
Expand Down

0 comments on commit c436428

Please sign in to comment.