Skip to content

Commit

Permalink
fixup! Deprecate ActionProtocol for swift(>=3.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharplet committed Feb 5, 2017
1 parent 822c052 commit 2e32503
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions Sources/Action.swift
Expand Up @@ -207,7 +207,7 @@ private struct ActionState {
}

/// A protocol used to constraint `Action` initializers.
@available(swift, deprecated: 3.1)
@available(swift, deprecated: 3.1, message: "This protocol is no longer necessary and will be removed in a future release of ReactiveSwift. Use Action directly instead.")
public protocol ActionProtocol {
/// The type of argument to apply the action to.
associatedtype Input
Expand Down Expand Up @@ -272,37 +272,6 @@ extension Action: ActionProtocol {
}
}

#if swift(>=3.1)
extension Action where Input == Void {
/// Initializes an action that uses an `Optional` property for its input,
/// and is disabled whenever the input is `nil`. When executed, a `SignalProducer`
/// is created with the current value of the input.
///
/// - parameters:
/// - input: An `Optional` property whose current value is used as input
/// whenever the action is executed. The action is disabled
/// whenever the value is `nil`.
/// - execute: A closure to return a new `SignalProducer` based on the
/// current value of `input`.
public convenience init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T? {
self.init(state: input, enabledIf: { $0 != nil }) { input, _ in
execute(input!)
}
}

/// Initializes an action that uses a property for its input. When executed,
/// a `SignalProducer` is created with the current value of the input.
///
/// - parameters:
/// - input: A property whose current value is used as input
/// whenever the action is executed.
/// - execute: A closure to return a new `SignalProducer` based on the
/// current value of `input`.
public convenience init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T {
self.init(input: input.map(Optional.some), execute)
}
}
#else
extension ActionProtocol where Input == Void {
/// Initializes an action that uses an `Optional` property for its input,
/// and is disabled whenever the input is `nil`. When executed, a `SignalProducer`
Expand Down Expand Up @@ -332,7 +301,6 @@ extension ActionProtocol where Input == Void {
self.init(input: input.map(Optional.some), execute)
}
}
#endif

/// The type of error that can occur from Action.apply, where `Error` is the
/// type of error that can be generated by the specific Action instance.
Expand Down

0 comments on commit 2e32503

Please sign in to comment.