Skip to content

Commit 5314acc

Browse files
NachoSotoandersio
authored andcommitted
Removing Result in favor of Swift.Result (#702)
* Removed Result * Removing Result from project * Added NoError and ResultProtocol for Swift.Result * Using Swift.Error in lieu of AnyError * Replaced NoError with Never * Test fixes * Specify the correct Error type in Never overloads * Fix tests * Update SwiftPM * Update CI * Remove the last vestiges of Result.framework * Rename assumeNevers back to assumeNoErrors
1 parent c37950d commit 5314acc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+970
-1140
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@
77
[submodule "Carthage/Checkouts/xcconfigs"]
88
path = Carthage/Checkouts/xcconfigs
99
url = https://github.com/jspahrsummers/xcconfigs.git
10-
[submodule "Carthage/Checkouts/Result"]
11-
path = Carthage/Checkouts/Result
12-
url = https://github.com/antitypical/Result.git

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.1
1+
5.0

.travis.yml

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
os: osx
22
language: objective-c
3-
osx_image: xcode10.1
3+
osx_image: xcode10.2
44
before_install: true
55
install: true
66
branches:
@@ -68,25 +68,10 @@ aliases:
6868
matrix:
6969
include:
7070
- <<: *xcode
71-
- <<: *xcode
72-
osx_image: xcode10.2
73-
# - <<: *xcode
74-
# osx_image: xcode10.2
75-
# env: XCODE_ARGS="SWIFT_VERSION=5.0"
7671
- <<: *cocoapods
7772
install: gem update cocoapods
7873
- <<: *swiftpm_darwin
79-
- <<: *swiftpm_darwin
80-
osx_image: xcode10.2
81-
- <<: *swiftpm_linux
8274
- <<: *swiftpm_linux
83-
env:
84-
- JOB=SwiftPM
85-
- SWIFT_VERSION=4.2.3
86-
- <<: *swiftpm_linux
87-
env:
88-
- JOB=SwiftPM
89-
- SWIFT_VERSION=5.0-DEVELOPMENT-SNAPSHOT-2019-02-28-a
9075
- stage: carthage
9176
script: carthage build --cache-builds --no-skip-current
9277
- stage: deploy

Cartfile

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
github "antitypical/Result" ~> 4.1

Cartfile.resolved

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
github "Quick/Nimble" "v8.0.0"
22
github "Quick/Quick" "v2.0.0"
3-
github "antitypical/Result" "4.1.0"
43
github "jspahrsummers/xcconfigs" "0.12"

Carthage/Checkouts/Result

-1
This file was deleted.

Package.resolved

-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@
1818
"revision": "0b4ed6c706dd0cce923b5019a605a9bcc6b1b600",
1919
"version": "2.0.0"
2020
}
21-
},
22-
{
23-
"package": "Result",
24-
"repositoryURL": "https://github.com/antitypical/Result.git",
25-
"state": {
26-
"branch": null,
27-
"revision": "2ca499ba456795616fbc471561ff1d963e6ae160",
28-
"version": "4.1.0"
29-
}
3021
}
3122
]
3223
},

Package.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22
import PackageDescription
33

44
let package = Package(
@@ -7,13 +7,12 @@ let package = Package(
77
.library(name: "ReactiveSwift", targets: ["ReactiveSwift"]),
88
],
99
dependencies: [
10-
.package(url: "https://github.com/antitypical/Result.git", from: "4.1.0"),
1110
.package(url: "https://github.com/Quick/Quick.git", from: "2.0.0"),
1211
.package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"),
1312
],
1413
targets: [
15-
.target(name: "ReactiveSwift", dependencies: ["Result"], path: "Sources"),
14+
.target(name: "ReactiveSwift", dependencies: [], path: "Sources"),
1615
.testTarget(name: "ReactiveSwiftTests", dependencies: ["ReactiveSwift", "Quick", "Nimble"]),
1716
],
18-
swiftLanguageVersions: [4]
17+
swiftLanguageVersions: [.v5]
1918
)

Package@swift-4.2.swift

-19
This file was deleted.

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ReactiveSwift to your `Cartfile`:
7575
github "ReactiveCocoa/ReactiveSwift" ~> 5.0
7676
```
7777

78-
If you use Carthage to build your dependencies, make sure you have added `ReactiveSwift.framework`, and `Result.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase.
78+
If you use Carthage to build your dependencies, make sure you have added `ReactiveSwift.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase.
7979

8080
#### CocoaPods
8181

@@ -100,12 +100,10 @@ of your package in `Package.swift`:
100100
1. Add the ReactiveSwift repository as a [submodule][] of your
101101
application’s repository.
102102
1. Run `git submodule update --init --recursive` from within the ReactiveCocoa folder.
103-
1. Drag and drop `ReactiveSwift.xcodeproj` and
104-
`Carthage/Checkouts/Result/Result.xcodeproj` into your application’s Xcode
103+
1. Drag and drop `ReactiveSwift.xcodeproj` into your application’s Xcode
105104
project or workspace.
106105
1. On the “General” tab of your application target’s settings, add
107-
`ReactiveSwift.framework`, and `Result.framework`
108-
to the “Embedded Binaries” section.
106+
`ReactiveSwift.framework` to the “Embedded Binaries” section.
109107
1. If your application target does not contain Swift code at all, you should also
110108
set the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting to “Yes”.
111109

ReactiveSwift-UIExamples.playground/Pages/ValidatingProperty.xcplaygroundpage/Contents.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
1. If you cannot see the playground live view, make sure the Timeline view has been selected for the Assistant Editor.
1414
*/
1515
import ReactiveSwift
16-
import Result
1716
import UIKit
1817
import PlaygroundSupport
1918

@@ -32,7 +31,7 @@ final class ViewModel {
3231

3332
let submit: Action<(), (), FormError>
3433

35-
let reasons: Signal<String, NoError>
34+
let reasons: Signal<String, Never>
3635

3736
init(userService: UserService) {
3837
// email: ValidatingProperty<String, FormError>
@@ -127,9 +126,9 @@ final class ViewController: UIViewController {
127126
}
128127

129128
final class UserService {
130-
let (requestSignal, requestObserver) = Signal<String, NoError>.pipe()
129+
let (requestSignal, requestObserver) = Signal<String, Never>.pipe()
131130

132-
func canUseUsername(_ string: String) -> SignalProducer<Bool, NoError> {
131+
func canUseUsername(_ string: String) -> SignalProducer<Bool, Never> {
133132
return SignalProducer { observer, disposable in
134133
self.requestObserver.send(value: string)
135134
observer.send(value: true)

ReactiveSwift-UIExamples.playground/Pages/ValidatingProperty.xcplaygroundpage/Sources/FormView.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22
import UIKit
33
import ReactiveSwift
4-
import Result
54

65
public class FormView: UIView {
76
let _lifetime = Lifetime.Token()

ReactiveSwift-UIExamples.playground/Pages/ValidatingProperty.xcplaygroundpage/Sources/UIKitExtensions.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22
import UIKit
33
import ReactiveSwift
4-
import enum Result.NoError
54

65
// These extensions mimics the ReactiveCocoa API, but not in a complete way.
76
//
@@ -62,7 +61,7 @@ extension Reactive where Base: UILabel {
6261
}
6362

6463
extension Reactive where Base: UISwitch {
65-
public var isOnValues: Signal<Bool, NoError> {
64+
public var isOnValues: Signal<Bool, Never> {
6665
return Signal { observer, lifetime in
6766
let target = CocoaTarget { observer.send(value: ($0 as! UISwitch).isOn) }
6867
base.addTarget(target, action: #selector(target.execute), for: .valueChanged)
@@ -72,7 +71,7 @@ extension Reactive where Base: UISwitch {
7271
}
7372

7473
extension Reactive where Base: UITextField {
75-
public var continuousTextValues: Signal<String?, NoError> {
74+
public var continuousTextValues: Signal<String?, Never> {
7675
return Signal { observer, lifetime in
7776
let target = CocoaTarget { observer.send(value: ($0 as! UITextField).text) }
7877
base.addTarget(target, action: #selector(target.execute), for: .editingChanged)

ReactiveSwift.playground/Pages/Property.xcplaygroundpage/Contents.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
1. Finally open the `ReactiveSwift.playground`
1212
1. Choose `View > Show Debug Area`
1313
*/
14-
import Result
1514
import ReactiveSwift
1615
import Foundation
1716
/*:
@@ -77,7 +76,7 @@ scopedExample("Creation") {
7776
property’s value is updated whenever the source property is updated.
7877
*/
7978
scopedExample("Binding from SignalProducer") {
80-
let producer = SignalProducer<Int, NoError> { observer, _ in
79+
let producer = SignalProducer<Int, Never> { observer, _ in
8180
print("New subscription, starting operation")
8281
observer.send(value: 1)
8382
observer.send(value: 2)
@@ -92,7 +91,7 @@ scopedExample("Binding from SignalProducer") {
9291
}
9392

9493
scopedExample("Binding from Signal") {
95-
let (signal, observer) = Signal<Int, NoError>.pipe()
94+
let (signal, observer) = Signal<Int, Never>.pipe()
9695
let property = MutableProperty(0)
9796
property.producer.startWithValues {
9897
print("Property received \($0)")

ReactiveSwift.playground/Pages/Sandbox.xcplaygroundpage/Contents.swift

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1. Choose `View > Show Debug Area`
1313
*/
1414

15-
import Result
1615
import ReactiveSwift
1716
import Foundation
1817

ReactiveSwift.playground/Pages/Signal.xcplaygroundpage/Contents.swift

+19-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1. Choose `View > Show Debug Area`
1313
*/
1414

15-
import Result
1615
import ReactiveSwift
1716
import Foundation
1817

@@ -53,10 +52,10 @@ Furthermore, the subscription to a signal does not trigger any side effects
5352
*/
5453
scopedExample("Subscription") {
5554
// Signal.pipe is a way to manually control a signal. the returned observer can be used to send values to the signal
56-
let (signal, observer) = Signal<Int, NoError>.pipe()
55+
let (signal, observer) = Signal<Int, Never>.pipe()
5756

58-
let subscriber1 = Signal<Int, NoError>.Observer(value: { print("Subscriber 1 received \($0)") } )
59-
let subscriber2 = Signal<Int, NoError>.Observer(value: { print("Subscriber 2 received \($0)") } )
57+
let subscriber1 = Signal<Int, Never>.Observer(value: { print("Subscriber 1 received \($0)") } )
58+
let subscriber2 = Signal<Int, Never>.Observer(value: { print("Subscriber 2 received \($0)") } )
6059

6160
print("Subscriber 1 subscribes to the signal")
6261
signal.observe(subscriber1)
@@ -79,9 +78,9 @@ scopedExample("Subscription") {
7978
A Signal that completes immediately without emitting any value.
8079
*/
8180
scopedExample("`empty`") {
82-
let emptySignal = Signal<Int, NoError>.empty
81+
let emptySignal = Signal<Int, Never>.empty
8382

84-
let observer = Signal<Int, NoError>.Observer(
83+
let observer = Signal<Int, Never>.Observer(
8584
value: { _ in print("value not called") },
8685
failed: { _ in print("error not called") },
8786
completed: { print("completed not called") },
@@ -96,9 +95,9 @@ scopedExample("`empty`") {
9695
A Signal that never sends any events to its observers.
9796
*/
9897
scopedExample("`never`") {
99-
let neverSignal = Signal<Int, NoError>.never
98+
let neverSignal = Signal<Int, Never>.never
10099

101-
let observer = Signal<Int, NoError>.Observer(
100+
let observer = Signal<Int, Never>.Observer(
102101
value: { _ in print("value not called") },
103102
failed: { _ in print("error not called") },
104103
completed: { print("completed not called") },
@@ -119,8 +118,8 @@ a function that returns a unique value for each sent value can help you reduce
119118
the memory footprint.
120119
*/
121120
scopedExample("`uniqueValues`") {
122-
let (signal, observer) = Signal<Int, NoError>.pipe()
123-
let subscriber = Signal<Int, NoError>.Observer(value: { print("Subscriber received \($0)") } )
121+
let (signal, observer) = Signal<Int, Never>.pipe()
122+
let subscriber = Signal<Int, Never>.Observer(value: { print("Subscriber received \($0)") } )
124123
let uniqueSignal = signal.uniqueValues()
125124

126125
uniqueSignal.observe(subscriber)
@@ -138,8 +137,8 @@ scopedExample("`uniqueValues`") {
138137
Maps each value in the signal to a new value.
139138
*/
140139
scopedExample("`map`") {
141-
let (signal, observer) = Signal<Int, NoError>.pipe()
142-
let subscriber = Signal<Int, NoError>.Observer(value: { print("Subscriber received \($0)") } )
140+
let (signal, observer) = Signal<Int, Never>.pipe()
141+
let subscriber = Signal<Int, Never>.Observer(value: { print("Subscriber received \($0)") } )
143142
let mappedSignal = signal.map { $0 * 2 }
144143

145144
mappedSignal.observe(subscriber)
@@ -171,8 +170,8 @@ scopedExample("`mapError`") {
171170
Preserves only the values of the signal that pass the given predicate.
172171
*/
173172
scopedExample("`filter`") {
174-
let (signal, observer) = Signal<Int, NoError>.pipe()
175-
let subscriber = Signal<Int, NoError>.Observer(value: { print("Subscriber received \($0)") } )
173+
let (signal, observer) = Signal<Int, Never>.pipe()
174+
let subscriber = Signal<Int, Never>.Observer(value: { print("Subscriber received \($0)") } )
176175
// subscriber will only receive events with values greater than 12
177176
let filteredSignal = signal.filter { $0 > 12 }
178177

@@ -190,10 +189,10 @@ Unwraps non-`nil` values and forwards them on the returned signal, `nil`
190189
values are dropped.
191190
*/
192191
scopedExample("`skipNil`") {
193-
let (signal, observer) = Signal<Int?, NoError>.pipe()
192+
let (signal, observer) = Signal<Int?, Never>.pipe()
194193
// note that the signal is of type `Int?` and observer is of type `Int`, given we're unwrapping
195194
// non-`nil` values
196-
let subscriber = Signal<Int, NoError>.Observer(value: { print("Subscriber received \($0)") } )
195+
let subscriber = Signal<Int, Never>.Observer(value: { print("Subscriber received \($0)") } )
197196
let skipNilSignal = signal.skipNil()
198197

199198
skipNilSignal.observe(subscriber)
@@ -207,8 +206,8 @@ scopedExample("`skipNil`") {
207206
Returns a signal that will yield the first `count` values from `self`
208207
*/
209208
scopedExample("`take(first:)`") {
210-
let (signal, observer) = Signal<Int, NoError>.pipe()
211-
let subscriber = Signal<Int, NoError>.Observer(value: { print("Subscriber received \($0)") } )
209+
let (signal, observer) = Signal<Int, Never>.pipe()
210+
let subscriber = Signal<Int, Never>.Observer(value: { print("Subscriber received \($0)") } )
212211
let takeSignal = signal.take(first: 2)
213212

214213
takeSignal.observe(subscriber)
@@ -225,10 +224,10 @@ Returns a signal that will yield an array of values when `self` completes.
225224
an empty array of values.
226225
*/
227226
scopedExample("`collect`") {
228-
let (signal, observer) = Signal<Int, NoError>.pipe()
227+
let (signal, observer) = Signal<Int, Never>.pipe()
229228
// note that the signal is of type `Int` and observer is of type `[Int]` given we're "collecting"
230229
// `Int` values for the lifetime of the signal
231-
let subscriber = Signal<[Int], NoError>.Observer(value: { print("Subscriber received \($0)") } )
230+
let subscriber = Signal<[Int], Never>.Observer(value: { print("Subscriber received \($0)") } )
232231
let collectSignal = signal.collect()
233232

234233
collectSignal.observe(subscriber)

0 commit comments

Comments
 (0)