|
1 | 1 | import Foundation |
2 | 2 | import enum Result.NoError |
3 | 3 |
|
| 4 | +// MARK: Obsolete types in ReactiveSwift 2.0. |
| 5 | +@available(*, unavailable, message: "This protocol has been removed. Constrain `Action` directly instead.") |
| 6 | +public protocol ActionProtocol {} |
| 7 | + |
| 8 | +@available(*, unavailable, message: "The protocol has been removed. Constrain `Observer` directly instead.") |
| 9 | +public protocol ObserverProtocol {} |
| 10 | + |
| 11 | +@available(*, unavailable, message:"The protocol has been replaced by `BindingTargetProvider`.") |
| 12 | +public protocol BindingTargetProtocol {} |
| 13 | + |
| 14 | +@available(*, unavailable, message:"The protocol has been removed. Constrain `Atomic` directly instead.") |
| 15 | +public protocol AtomicProtocol {} |
| 16 | + |
4 | 17 | // MARK: Depreciated types in ReactiveSwift 1.x. |
5 | 18 | extension Signal where Value == Bool { |
6 | 19 | @available(*, deprecated, renamed: "negate()") |
@@ -32,90 +45,6 @@ public typealias DateSchedulerProtocol = DateScheduler |
32 | 45 | @available(*, deprecated, renamed:"BindingSource") |
33 | 46 | public typealias BindingSourceProtocol = BindingSource |
34 | 47 |
|
35 | | -@available(*, deprecated, message:"The protocol has been replaced by `BindingTargetProvider`, and will be removed in a future version.") |
36 | | -public protocol BindingTargetProtocol: class, BindingTargetProvider { |
37 | | - var lifetime: Lifetime { get } |
38 | | - |
39 | | - func consume(_ value: Value) |
40 | | -} |
41 | | - |
42 | | -extension BindingTargetProtocol { |
43 | | - public var bindingTarget: BindingTarget<Value> { |
44 | | - return BindingTarget(lifetime: lifetime) { [weak self] in self?.consume($0) } |
45 | | - } |
46 | | -} |
47 | | - |
48 | | -extension MutablePropertyProtocol { |
49 | | - @available(*, deprecated, message:"Use the regular setter.") |
50 | | - public func consume(_ value: Value) { |
51 | | - self.value = value |
52 | | - } |
53 | | -} |
54 | | - |
55 | | -extension Action: BindingTargetProtocol { |
56 | | - @available(*, deprecated, message:"Use the regular SignalProducer.") |
57 | | - public func consume(_ value: Input) { |
58 | | - self.apply(value).start() |
59 | | - } |
60 | | -} |
61 | | - |
62 | | -extension BindingTarget { |
63 | | - @available(*, deprecated, renamed:"action") |
64 | | - public func consume(_ value: Value) { |
65 | | - action(value) |
66 | | - } |
67 | | - |
68 | | - @available(*, deprecated, renamed:"init(lifetime:action:)") |
69 | | - public init(lifetime: Lifetime, setter: @escaping (Value) -> Void, _ void: Void? = nil) { |
70 | | - self.init(lifetime: lifetime, action: setter) |
71 | | - } |
72 | | - |
73 | | - @available(*, deprecated, renamed:"init(on:lifetime:action:)") |
74 | | - public init(on scheduler: Scheduler, lifetime: Lifetime, setter: @escaping (Value) -> Void, _ void: Void? = nil) { |
75 | | - self.init(on: scheduler, lifetime: lifetime, action: setter) |
76 | | - } |
77 | | -} |
78 | | - |
79 | | -/// A protocol used to constraint convenience `Atomic` methods and properties. |
80 | | -@available(*, deprecated, message:"The protocol has been deprecated, and will be removed in a future version.") |
81 | | -public protocol AtomicProtocol: class { |
82 | | - associatedtype Value |
83 | | - |
84 | | - @discardableResult |
85 | | - func withValue<Result>(_ action: (Value) throws -> Result) rethrows -> Result |
86 | | - |
87 | | - @discardableResult |
88 | | - func modify<Result>(_ action: (inout Value) throws -> Result) rethrows -> Result |
89 | | -} |
90 | | - |
91 | | -extension AtomicProtocol { |
92 | | - /// Atomically get or set the value of the variable. |
93 | | - public var value: Value { |
94 | | - get { |
95 | | - return withValue { $0 } |
96 | | - } |
97 | | - |
98 | | - set(newValue) { |
99 | | - swap(newValue) |
100 | | - } |
101 | | - } |
102 | | - |
103 | | - /// Atomically replace the contents of the variable. |
104 | | - /// |
105 | | - /// - parameters: |
106 | | - /// - newValue: A new value for the variable. |
107 | | - /// |
108 | | - /// - returns: The old value. |
109 | | - @discardableResult |
110 | | - public func swap(_ newValue: Value) -> Value { |
111 | | - return modify { (value: inout Value) in |
112 | | - let oldValue = value |
113 | | - value = newValue |
114 | | - return oldValue |
115 | | - } |
116 | | - } |
117 | | -} |
118 | | - |
119 | 48 | // MARK: Removed Types and APIs in ReactiveCocoa 5.0. |
120 | 49 |
|
121 | 50 | // Renamed Protocols |
@@ -180,7 +109,7 @@ extension ScopedDisposable { |
180 | 109 | public var innerDisposable: Disposable { fatalError() } |
181 | 110 | } |
182 | 111 |
|
183 | | -extension ActionProtocol { |
| 112 | +extension Action { |
184 | 113 | @available(*, unavailable, renamed:"isEnabled") |
185 | 114 | public var enabled: Bool { fatalError() } |
186 | 115 |
|
@@ -286,9 +215,7 @@ extension Observer { |
286 | 215 | completed: (() -> Void)? = nil, |
287 | 216 | interrupted: (() -> Void)? = nil |
288 | 217 | ) { fatalError() } |
289 | | -} |
290 | 218 |
|
291 | | -extension ObserverProtocol { |
292 | 219 | @available(*, unavailable, renamed: "send(value:)") |
293 | 220 | public func sendNext(_ value: Value) { fatalError() } |
294 | 221 |
|
|
0 commit comments