Skip to content

Commit 643e2f0

Browse files
authored
Merge branch 'master' into 3.1-concrete-same-type-req-2
2 parents 5c07ffa + 51d0230 commit 643e2f0

File tree

13 files changed

+192
-382
lines changed

13 files changed

+192
-382
lines changed

.jazzy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ custom_categories:
4040
- DateScheduler
4141
- Scheduler
4242
- name: Schedulers
43+
children:
4344
- ImmediateScheduler
4445
- QueueScheduler
4546
- TestScheduler
@@ -62,6 +63,7 @@ custom_categories:
6263
- SimpleDisposable
6364
- +=(_:_:)
6465
- name: Debugging
66+
children:
6567
- EventLogger
6668
- LoggingEvent
6769
- name: Utilities
@@ -73,6 +75,7 @@ custom_categories:
7375
- Optional
7476
- OptionalProtocol
7577
- name: Deprecated
78+
children:
7679
- AtomicProtocol
7780
- ActionProtocol
7881
- BindingTargetProtocol

ReactiveSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "ReactiveSwift"
33
# Version goes here and will be used to access the git tag later on, once we have a first release.
4-
s.version = "1.1.0"
4+
s.version = "1.1.1"
55
s.summary = "Streams of values over time"
66
s.description = <<-DESC
77
ReactiveSwift is a Swift framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values over time.

Sources/Action.swift

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -206,71 +206,13 @@ private struct ActionState {
206206
}
207207
}
208208

209-
/// A protocol used to constraint `Action` initializers.
210-
@available(swift, deprecated: 3.1, message: "This protocol is no longer necessary and will be removed in a future version of ReactiveSwift. Use Action directly instead.")
211-
public protocol ActionProtocol: BindingTargetProvider, BindingTargetProtocol {
212-
/// The type of argument to apply the action to.
213-
associatedtype Input
214-
/// The type of values returned by the action.
215-
associatedtype Output
216-
/// The type of error when the action fails. If errors aren't possible then
217-
/// `NoError` can be used.
218-
associatedtype Error: Swift.Error
219-
220-
/// Initializes an action that will be conditionally enabled based on the
221-
/// value of `state`. Creates a `SignalProducer` for each input and the
222-
/// current value of `state`.
223-
///
224-
/// - note: `Action` guarantees that changes to `state` are observed in a
225-
/// thread-safe way. Thus, the value passed to `isEnabled` will
226-
/// always be identical to the value passed to `execute`, for each
227-
/// application of the action.
228-
///
229-
/// - note: This initializer should only be used if you need to provide
230-
/// custom input can also influence whether the action is enabled.
231-
/// The various convenience initializers should cover most use cases.
232-
///
233-
/// - parameters:
234-
/// - state: A property that provides the current state of the action
235-
/// whenever `apply()` is called.
236-
/// - enabledIf: A predicate that, given the current value of `state`,
237-
/// returns whether the action should be enabled.
238-
/// - execute: A closure that returns the `SignalProducer` returned by
239-
/// calling `apply(Input)` on the action, optionally using
240-
/// the current value of `state`.
241-
init<State: PropertyProtocol>(state property: State, enabledIf isEnabled: @escaping (State.Value) -> Bool, _ execute: @escaping (State.Value, Input) -> SignalProducer<Output, Error>)
242-
243-
/// Whether the action is currently enabled.
244-
var isEnabled: Property<Bool> { get }
245-
246-
/// Extracts an action from the receiver.
247-
var action: Action<Input, Output, Error> { get }
248-
249-
/// Creates a SignalProducer that, when started, will execute the action
250-
/// with the given input, then forward the results upon the produced Signal.
251-
///
252-
/// - note: If the action is disabled when the returned SignalProducer is
253-
/// started, the produced signal will send `ActionError.disabled`,
254-
/// and nothing will be sent upon `values` or `errors` for that
255-
/// particular signal.
256-
///
257-
/// - parameters:
258-
/// - input: A value that will be passed to the closure creating the signal
259-
/// producer.
260-
func apply(_ input: Input) -> SignalProducer<Output, ActionError<Error>>
261-
}
262-
263-
extension Action: ActionProtocol {
264-
public var action: Action {
265-
return self
266-
}
267-
209+
extension Action: BindingTargetProvider {
268210
public var bindingTarget: BindingTarget<Input> {
269211
return BindingTarget(lifetime: lifetime) { [weak self] in self?.apply($0).start() }
270212
}
271213
}
272214

273-
extension ActionProtocol where Input == Void {
215+
extension Action where Input == Void {
274216
/// Initializes an action that uses an `Optional` property for its input,
275217
/// and is disabled whenever the input is `nil`. When executed, a `SignalProducer`
276218
/// is created with the current value of the input.
@@ -281,7 +223,7 @@ extension ActionProtocol where Input == Void {
281223
/// whenever the value is `nil`.
282224
/// - execute: A closure to return a new `SignalProducer` based on the
283225
/// current value of `input`.
284-
public init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T? {
226+
public convenience init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T? {
285227
self.init(state: input, enabledIf: { $0 != nil }) { input, _ in
286228
execute(input!)
287229
}
@@ -295,7 +237,7 @@ extension ActionProtocol where Input == Void {
295237
/// whenever the action is executed.
296238
/// - execute: A closure to return a new `SignalProducer` based on the
297239
/// current value of `input`.
298-
public init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T {
240+
public convenience init<P: PropertyProtocol, T>(input: P, _ execute: @escaping (T) -> SignalProducer<Output, Error>) where P.Value == T {
299241
self.init(input: input.map(Optional.some), execute)
300242
}
301243
}

Sources/Atomic.swift

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,10 @@ import Foundation
1111
import MachO
1212
#endif
1313

14-
/// Represents a finite state machine that can transit from one state to
15-
/// another.
16-
internal protocol AtomicStateProtocol {
17-
associatedtype State: RawRepresentable
18-
19-
/// Try to transition from the expected current state to the specified next
20-
/// state.
21-
///
22-
/// - parameters:
23-
/// - expected: The expected state.
24-
/// - next: The state to transition to.
25-
///
26-
/// - returns:
27-
/// `true` if the transition succeeds. `false` otherwise.
28-
func tryTransition(from expected: State, to next: State) -> Bool
29-
}
30-
3114
/// A simple, generic lock-free finite state machine.
3215
///
3316
/// - warning: `deinitialize` must be called to dispose of the consumed memory.
34-
internal struct UnsafeAtomicState<State: RawRepresentable>: AtomicStateProtocol where State.RawValue == Int32 {
17+
internal struct UnsafeAtomicState<State: RawRepresentable> where State.RawValue == Int32 {
3518
internal typealias Transition = (expected: State, next: State)
3619
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
3720
private let value: UnsafeMutablePointer<Int32>
@@ -150,7 +133,7 @@ final class PosixThreadMutex: NSLocking {
150133
}
151134

152135
/// An atomic variable.
153-
public final class Atomic<Value>: AtomicProtocol {
136+
public final class Atomic<Value> {
154137
private let lock: PosixThreadMutex
155138
private var _value: Value
156139

@@ -221,7 +204,7 @@ public final class Atomic<Value>: AtomicProtocol {
221204

222205

223206
/// An atomic variable which uses a recursive lock.
224-
internal final class RecursiveAtomic<Value>: AtomicProtocol {
207+
internal final class RecursiveAtomic<Value> {
225208
private let lock: NSRecursiveLock
226209
private var _value: Value
227210
private let didSetObserver: ((Value) -> Void)?

Sources/Deprecations+Removals.swift

Lines changed: 14 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import Foundation
22
import enum Result.NoError
33

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+
417
// MARK: Depreciated types in ReactiveSwift 1.x.
518
extension Signal where Value == Bool {
619
@available(*, deprecated, renamed: "negate()")
@@ -32,90 +45,6 @@ public typealias DateSchedulerProtocol = DateScheduler
3245
@available(*, deprecated, renamed:"BindingSource")
3346
public typealias BindingSourceProtocol = BindingSource
3447

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-
11948
// MARK: Removed Types and APIs in ReactiveCocoa 5.0.
12049

12150
// Renamed Protocols
@@ -180,7 +109,7 @@ extension ScopedDisposable {
180109
public var innerDisposable: Disposable { fatalError() }
181110
}
182111

183-
extension ActionProtocol {
112+
extension Action {
184113
@available(*, unavailable, renamed:"isEnabled")
185114
public var enabled: Bool { fatalError() }
186115

@@ -286,9 +215,7 @@ extension Observer {
286215
completed: (() -> Void)? = nil,
287216
interrupted: (() -> Void)? = nil
288217
) { fatalError() }
289-
}
290218

291-
extension ObserverProtocol {
292219
@available(*, unavailable, renamed: "send(value:)")
293220
public func sendNext(_ value: Value) { fatalError() }
294221

Sources/Disposable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private enum DisposableState: Int32 {
2828
case disposed
2929
}
3030

31-
extension AtomicStateProtocol where State == DisposableState {
31+
extension UnsafeAtomicState where State == DisposableState {
3232
/// Try to transition from `active` to `disposed`.
3333
///
3434
/// - returns:

0 commit comments

Comments
 (0)