Skip to content
This repository was archived by the owner on Jul 3, 2022. It is now read-only.

Commit 7e08010

Browse files
committed
Merge branch 'possen-swift4.0beta'
2 parents f18744a + 17a4479 commit 7e08010

17 files changed

+93
-72
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode8
2+
osx_image: xcode9
33

44
script:
55
- xcodebuild test -workspace BrightFutures.xcworkspace -scheme BrightFutures-Mac

BrightFutures.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'BrightFutures'
3-
s.version = '5.2.0'
3+
s.version = '6.0.0-beta.1'
44
s.license = 'MIT'
55
s.summary = 'Write great asynchronous code in Swift using futures and promises'
66
s.homepage = 'https://github.com/Thomvis/BrightFutures'
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
1919

2020
s.requires_arc = true
2121

22-
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }
22+
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
2323
end

BrightFutures.xcodeproj/project.pbxproj

Lines changed: 56 additions & 39 deletions
Large diffs are not rendered by default.

BrightFutures.xcodeproj/xcshareddata/xcschemes/BrightFutures-Mac.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

BrightFutures.xcodeproj/xcshareddata/xcschemes/BrightFutures-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

BrightFutures.xcodeproj/xcshareddata/xcschemes/BrightFutures-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

BrightFutures.xcodeproj/xcshareddata/xcschemes/BrightFutures-watchOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "antitypical/Result" "3.2.1"
1+
github "antitypical/Result" "3.2.3"

Sources/BrightFutures/AsyncType+Debug.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ public extension LoggerType {
2929
}
3030
}
3131

32-
fileprivate struct Logger: LoggerType {
33-
func log(message: String) {
32+
public struct Logger: LoggerType {
33+
public init() {
34+
}
35+
36+
public func log(message: String) {
3437
print(message)
3538
}
3639
}

Sources/BrightFutures/AsyncType+ResultType.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public extension AsyncType where Value: ResultProtocol {
117117
/// This function should be used in cases where there are two asynchronous operations where the second operation (returned from the given closure)
118118
/// should only be executed if the first (this future) fails.
119119
/// The closure is executed on the given context. If no context is given, the behavior is defined by the default threading model (see README.md)
120-
public func recoverWith<E1: Error>(context c: @escaping ExecutionContext = DefaultThreadingModel(), task: @escaping (Value.Error) -> Future<Value.Value, E1>) -> Future<Value.Value, E1> {
120+
public func recoverWith<E1>(context c: @escaping ExecutionContext = DefaultThreadingModel(), task: @escaping (Value.Error) -> Future<Value.Value, E1>) -> Future<Value.Value, E1> {
121121
let res = Future<Value.Value, E1>()
122122

123123
self.onComplete(c) { result in
@@ -131,14 +131,14 @@ public extension AsyncType where Value: ResultProtocol {
131131

132132
/// See `mapError<E1>(context c: ExecutionContext, f: E -> E1) -> Future<T, E1>`
133133
/// The given closure is executed according to the default threading model (see README.md)
134-
public func mapError<E1: Error>(_ f: @escaping (Value.Error) -> E1) -> Future<Value.Value, E1> {
134+
public func mapError<E1>(_ f: @escaping (Value.Error) -> E1) -> Future<Value.Value, E1> {
135135
return mapError(DefaultThreadingModel(), f: f)
136136
}
137137

138138
/// Returns a future that fails with the error returned from the given closure when it is invoked with the error
139139
/// from this future. If this future succeeds, the returned future succeeds with the same value and the closure is not executed.
140140
/// The closure is executed on the given context.
141-
public func mapError<E1: Error>(_ context: @escaping ExecutionContext, f: @escaping (Value.Error) -> E1) -> Future<Value.Value, E1> {
141+
public func mapError<E1>(_ context: @escaping ExecutionContext, f: @escaping (Value.Error) -> E1) -> Future<Value.Value, E1> {
142142
let res = Future<Value.Value, E1>()
143143

144144
self.onComplete(context) { result in
@@ -216,7 +216,7 @@ public extension AsyncType where Value: ResultProtocol, Value.Error == NoError {
216216
/// This allows the `Future` to be used more easily in combination with other futures
217217
/// for operations such as `sequence` and `firstCompleted`
218218
/// This is a safe operation, because a `Future` with error type `NoError` is guaranteed never to fail
219-
public func promoteError<E: Error>() -> Future<Value.Value, E> {
219+
public func promoteError<E>() -> Future<Value.Value, E> {
220220
return mapError(ImmediateExecutionContext) { $0 as! E } // future will never fail, so this map block will never get called
221221
}
222222
}
@@ -227,7 +227,7 @@ public extension AsyncType where Value: ResultProtocol, Value.Error == BrightFut
227227
/// This allows the `Future` to be used more easily in combination with other futures
228228
/// for operations such as `sequence` and `firstCompleted`
229229
/// This is a safe operation, because a `BrightFuturesError<NoError>` will never be `.External`
230-
public func promoteError<E: Error>() -> Future<Value.Value, BrightFuturesError<E>> {
230+
public func promoteError<E>() -> Future<Value.Value, BrightFuturesError<E>> {
231231
return mapError(ImmediateExecutionContext) { err in
232232
switch err {
233233
case .noSuchElement:

Sources/BrightFutures/Dispatch+BrightFutures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public extension DispatchQueue {
2424
}
2525
}
2626

27-
public func asyncResult<T, E: Error>(_ execute: @escaping () -> Result<T, E>) -> Future<T, E> {
27+
public func asyncResult<T, E>(_ execute: @escaping () -> Result<T, E>) -> Future<T, E> {
2828
return Future { completion in
2929
async {
3030
completion(execute())

Sources/BrightFutures/ExecutionContext.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ public let MaxStackDepthExecutionContext: ExecutionContext = { task in
6565
}
6666
}
6767

68-
typealias ThreadingModel = () -> ExecutionContext
68+
public typealias ThreadingModel = () -> ExecutionContext
6969

70-
var DefaultThreadingModel: ThreadingModel = defaultContext
70+
public var DefaultThreadingModel: ThreadingModel = defaultContext
7171

7272
/// Defines BrightFutures' default threading behavior:
7373
/// - if on the main thread, `DispatchQueue.main.context` is returned
7474
/// - if off the main thread, `DispatchQueue.global().context` is returned
75-
func defaultContext() -> ExecutionContext {
75+
public func defaultContext() -> ExecutionContext {
7676
return (Thread.isMainThread ? DispatchQueue.main : DispatchQueue.global()).context
7777
}

Sources/BrightFutures/Future.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class Future<T, E: Error>: Async<Result<T, E>> {
7171

7272
}
7373

74-
public func materialize<T, E: Error>(_ scope: ((T?, E?) -> Void) -> Void) -> Future<T, E> {
74+
public func materialize<T, E>(_ scope: ((T?, E?) -> Void) -> Void) -> Future<T, E> {
7575
return Future { complete in
7676
scope { val, err in
7777
if let val = val {
@@ -91,13 +91,13 @@ public func materialize<T>(_ scope: ((T) -> Void) -> Void) -> Future<T, NoError>
9191
}
9292
}
9393

94-
public func materialize<E: Error>(_ scope: ((E?) -> Void) -> Void) -> Future<Void, E> {
94+
public func materialize<E>(_ scope: ((E?) -> Void) -> Void) -> Future<Void, E> {
9595
return Future { complete in
9696
scope { err in
9797
if let err = err {
9898
complete(.failure(err))
9999
} else {
100-
complete(.success())
100+
complete(.success(()))
101101
}
102102
}
103103
}

Tests/BrightFuturesTests/BrightFuturesTests.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ extension BrightFuturesTests {
379379
func testSkippedRecover() {
380380
let e = self.expectation()
381381

382-
DispatchQueue.global().asyncValue { _ in
382+
DispatchQueue.global().asyncValue {
383383
3
384384
}.recover { _ in
385385
XCTFail("recover task should not be executed")
@@ -411,7 +411,7 @@ extension BrightFuturesTests {
411411
DispatchQueue.global().asyncResult {
412412
Result(error: NSError(domain: "NaN", code: 0, userInfo: nil))
413413
}.recoverWith { _ in
414-
return DispatchQueue.global().asyncValue { _ in
414+
return DispatchQueue.global().asyncValue {
415415
fibonacci(5)
416416
}
417417
}.onSuccess { value in
@@ -450,7 +450,8 @@ extension BrightFuturesTests {
450450

451451
let e = self.expectation()
452452

453-
f.zip(f1).onSuccess { (a, b) in
453+
f.zip(f1).onSuccess { (arg) in
454+
let (a, b) = arg
454455
XCTAssertEqual(a, 1)
455456
XCTAssertEqual(b, 2)
456457
e.fulfill()
@@ -742,7 +743,7 @@ extension BrightFuturesTests {
742743
let e = self.expectation()
743744

744745
let evenFuture: (Int) -> Future<Bool, NSError> = { i in
745-
return DispatchQueue.global().asyncResult { err in
746+
return DispatchQueue.global().asyncResult {
746747
if i % 2 == 0 {
747748
return Result(value: true)
748749
} else {
@@ -1082,7 +1083,7 @@ extension BrightFuturesTests {
10821083
}
10831084
}
10841085

1085-
p.success()
1086+
p.success(())
10861087

10871088
self.waitForExpectations(timeout: 5, handler: nil)
10881089
}
@@ -1137,14 +1138,14 @@ extension XCTestCase {
11371138
}
11381139

11391140
func failingFuture<U>() -> Future<U, NSError> {
1140-
return DispatchQueue.global().asyncResult { error in
1141+
return DispatchQueue.global().asyncResult {
11411142
usleep(arc4random_uniform(100))
11421143
return Result(error: NSError(domain: "failedFuture", code: 0, userInfo: nil))
11431144
}
11441145
}
11451146

11461147
func succeedingFuture<U>(_ val: U) -> Future<U, NSError> {
1147-
return DispatchQueue.global().asyncResult { _ in
1148+
return DispatchQueue.global().asyncResult {
11481149
usleep(arc4random_uniform(100))
11491150
return Result(value: val)
11501151
}

Tests/BrightFuturesTests/FutureDebugTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FutureDebugTests: XCTestCase {
3232
let expectedMessage = "\(fileName) at line \(line), func: \(function) - future completed"
3333
let debugExpectation = self.expectation(description: "debugLogged")
3434

35-
f.onSuccess {
35+
f.onSuccess { _ in
3636
XCTAssertEqual(logger.lastLoggedMessage, expectedMessage)
3737
debugExpectation.fulfill()
3838
}
@@ -46,7 +46,7 @@ class FutureDebugTests: XCTestCase {
4646
let f = Future<Void, NoError>(value: ()).debug(testIdentifier, logger: logger)
4747
let debugExpectation = self.expectation(description: "debugLogged")
4848

49-
f.onSuccess {
49+
f.onSuccess { _ in
5050
XCTAssertEqual(logger.lastLoggedMessage, "Future \(self.testIdentifier) completed")
5151
debugExpectation.fulfill()
5252
}

0 commit comments

Comments
 (0)