Skip to content

Commit dd8027b

Browse files
author
Kacper
authored
Update to swift 5
1 parent 59a9f01 commit dd8027b

18 files changed

+484
-382
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
fastlane/report.xml
44

55
## Build generated
6+
.build/
67
build/
78
DerivedData
89

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: swift
2-
osx_image: xcode10
2+
osx_image: xcode10.2
33

44
script:
55
- swift package generate-xcodeproj

Futura.xcodeproj/project.pbxproj

Lines changed: 316 additions & 278 deletions
Large diffs are not rendered by default.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1020"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "Futura::FuturaPackageTests::ProductTarget"
18+
BuildableName = "FuturaPackageTests"
19+
BlueprintName = "FuturaPackageTests"
20+
ReferencedContainer = "container:Futura.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
codeCoverageEnabled = "YES"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
</Testables>
33+
<AdditionalOptions>
34+
</AdditionalOptions>
35+
</TestAction>
36+
<LaunchAction
37+
buildConfiguration = "Debug"
38+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
39+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
launchStyle = "0"
41+
useCustomWorkingDirectory = "NO"
42+
ignoresPersistentStateOnLaunch = "NO"
43+
debugDocumentVersioning = "YES"
44+
debugServiceExtension = "internal"
45+
allowLocationSimulation = "YES">
46+
<MacroExpansion>
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "Futura::FuturaPackageTests::ProductTarget"
50+
BuildableName = "FuturaPackageTests"
51+
BlueprintName = "FuturaPackageTests"
52+
ReferencedContainer = "container:Futura.xcodeproj">
53+
</BuildableReference>
54+
</MacroExpansion>
55+
<AdditionalOptions>
56+
</AdditionalOptions>
57+
</LaunchAction>
58+
<ProfileAction
59+
buildConfiguration = "Release"
60+
shouldUseLaunchSchemeArgsEnv = "YES"
61+
savedToolIdentifier = ""
62+
useCustomWorkingDirectory = "NO"
63+
debugDocumentVersioning = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "Futura::FuturaPackageTests::ProductTarget"
68+
BuildableName = "FuturaPackageTests"
69+
BlueprintName = "FuturaPackageTests"
70+
ReferencedContainer = "container:Futura.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
</ProfileAction>
74+
<AnalyzeAction
75+
buildConfiguration = "Debug">
76+
</AnalyzeAction>
77+
<ArchiveAction
78+
buildConfiguration = "Release"
79+
revealArchiveInOrganizer = "YES">
80+
</ArchiveAction>
81+
</Scheme>

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22

33
import PackageDescription
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![codecov](https://codecov.io/gh/miquido/futura/branch/master/graph/badge.svg)](https://codecov.io/gh/miquido/futura)
55
[![Platforms](https://img.shields.io/badge/platform-iOS%20|%20macOS-gray.svg?style=flat)]()
66
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
7-
[![SwiftVersion](https://img.shields.io/badge/Swift-4.2-brightgreen.svg)]()
7+
[![SwiftVersion](https://img.shields.io/badge/Swift-5.0-brightgreen.svg)]()
88

99
Futura is a library that provides simple yet powerful tools for working with asynchronous and concurrent code in Swift.
1010

Sources/Futura/Future/Future.swift

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public final class Future<Value> {
2828
/// - Parameter executionContext: ExecutionContext that will be used for all
2929
/// transformations and handlers made on this Future. Default is .undefined.
3030
public convenience init(succeededWith result: Value, executionContext: ExecutionContext = .undefined) {
31-
self.init(with: .value(result), executionContext: executionContext)
31+
self.init(with: .success(result), executionContext: executionContext)
3232
}
3333

3434
/// Creates already finished Future with given error and context.
@@ -37,10 +37,10 @@ public final class Future<Value> {
3737
/// - Parameter executionContext: ExecutionContext that will be used for all
3838
/// transformations and handlers made on this Future. Default is .undefined.
3939
public convenience init(failedWith reason: Error, executionContext: ExecutionContext = .undefined) {
40-
self.init(with: .error(reason), executionContext: executionContext)
40+
self.init(with: .failure(reason), executionContext: executionContext)
4141
}
4242

43-
internal init(with result: Result<Value>? = nil, executionContext: ExecutionContext) {
43+
internal init(with result: Result<Value, Error>? = nil, executionContext: ExecutionContext) {
4444
self.executionContext = executionContext
4545
if let result = result {
4646
self.state = .resulted(with: result)
@@ -73,7 +73,7 @@ public extension Future {
7373
@discardableResult
7474
func value(_ handler: @escaping (Value) -> Void) -> Self {
7575
observe { state in
76-
guard case let .resulted(.value(value)) = state else { return }
76+
guard case let .resulted(.success(value)) = state else { return }
7777
handler(value)
7878
}
7979
return self
@@ -90,7 +90,7 @@ public extension Future {
9090
@discardableResult
9191
func error(_ handler: @escaping (Error) -> Void) -> Self {
9292
observe { state in
93-
guard case let .resulted(.error(reason)) = state else { return }
93+
guard case let .resulted(.failure(reason)) = state else { return }
9494
handler(reason)
9595
}
9696
return self
@@ -141,14 +141,14 @@ public extension Future {
141141
let future: Future<T> = .init(executionContext: executionContext)
142142
observe { state in
143143
switch state {
144-
case let .resulted(.value(value)):
144+
case let .resulted(.success(value)):
145145
do {
146-
try future.become(.resulted(with: .value(transformation(value))))
146+
try future.become(.resulted(with: .success(transformation(value))))
147147
} catch {
148-
future.become(.resulted(with: .error(error)))
148+
future.become(.resulted(with: .failure(error)))
149149
}
150-
case let .resulted(.error(reason)):
151-
future.become(.resulted(with: .error(reason)))
150+
case let .resulted(.failure(reason)):
151+
future.become(.resulted(with: .failure(reason)))
152152
case .canceled:
153153
future.become(.canceled)
154154
case .waiting: break
@@ -171,16 +171,16 @@ public extension Future {
171171
let future: Future<T> = .init(executionContext: executionContext)
172172
observe { state in
173173
switch state {
174-
case let .resulted(.value(value)):
174+
case let .resulted(.success(value)):
175175
do {
176176
try transformation(value).observe {
177177
future.become($0)
178178
}
179179
} catch {
180-
future.become(.resulted(with: .error(error)))
180+
future.become(.resulted(with: .failure(error)))
181181
}
182-
case let .resulted(.error(reason)):
183-
future.become(.resulted(with: .error(reason)))
182+
case let .resulted(.failure(reason)):
183+
future.become(.resulted(with: .failure(reason)))
184184
case .canceled:
185185
future.become(.canceled)
186186
case .waiting: break
@@ -216,14 +216,14 @@ public extension Future {
216216
let future: Future<Value> = .init(executionContext: executionContext)
217217
observe { state in
218218
switch state {
219-
case let .resulted(.value(value)):
220-
future.become(.resulted(with: .value(value)))
221-
case let .resulted(.error(reason)):
219+
case let .resulted(.success(value)):
220+
future.become(.resulted(with: .success(value)))
221+
case let .resulted(.failure(reason)):
222222
do {
223223
try transformation(reason)
224224
future.become(.canceled)
225225
} catch {
226-
future.become(.resulted(with: .error(error)))
226+
future.become(.resulted(with: .failure(error)))
227227
}
228228
case .canceled:
229229
future.become(.canceled)
@@ -247,13 +247,13 @@ public extension Future {
247247
let future: Future<Value> = .init(executionContext: executionContext)
248248
observe { state in
249249
switch state {
250-
case let .resulted(.value(value)):
251-
future.become(.resulted(with: .value(value)))
252-
case let .resulted(.error(reason)):
250+
case let .resulted(.success(value)):
251+
future.become(.resulted(with: .success(value)))
252+
case let .resulted(.failure(reason)):
253253
do {
254-
try future.become(.resulted(with: .value(transformation(reason))))
254+
try future.become(.resulted(with: .success(transformation(reason))))
255255
} catch {
256-
future.become(.resulted(with: .error(error)))
256+
future.become(.resulted(with: .failure(error)))
257257
}
258258
case .canceled:
259259
future.become(.canceled)
@@ -283,7 +283,7 @@ public extension Future {
283283
internal extension Future {
284284
enum State {
285285
case waiting
286-
case resulted(with: Result<Value>)
286+
case resulted(with: Result<Value, Error>)
287287
case canceled
288288
}
289289

@@ -336,33 +336,33 @@ public func zip<T, U>(_ f1: Future<T>, _ f2: Future<U>) -> Future<(T, U)> {
336336

337337
f1.observe { state in
338338
switch state {
339-
case let .resulted(.value(value)):
339+
case let .resulted(.success(value)):
340340
lock.lock()
341341
defer { lock.unlock() }
342342
if case let (_, r2?) = results {
343-
future.become(.resulted(with: .value((value, r2))))
343+
future.become(.resulted(with: .success((value, r2))))
344344
} else {
345345
results = (value, nil)
346346
}
347-
case let .resulted(.error(reason)):
348-
future.become(.resulted(with: .error(reason)))
347+
case let .resulted(.failure(reason)):
348+
future.become(.resulted(with: .failure(reason)))
349349
case .canceled:
350350
future.become(.canceled)
351351
case .waiting: break
352352
}
353353
}
354354
f2.observe { state in
355355
switch state {
356-
case let .resulted(.value(value)):
356+
case let .resulted(.success(value)):
357357
lock.lock()
358358
defer { lock.unlock() }
359359
if case let (r1?, _) = results {
360-
future.become(.resulted(with: .value((r1, value))))
360+
future.become(.resulted(with: .success((r1, value))))
361361
} else {
362362
results = (nil, value)
363363
}
364-
case let .resulted(.error(reason)):
365-
future.become(.resulted(with: .error(reason)))
364+
case let .resulted(.failure(reason)):
365+
future.become(.resulted(with: .failure(reason)))
366366
case .canceled:
367367
future.become(.canceled)
368368
case .waiting: break
@@ -388,14 +388,14 @@ public func zip<T>(_ futures: [Future<T>]) -> Future<[T]> {
388388
for future in futures {
389389
future.observe { state in
390390
switch state {
391-
case let .resulted(.value(value)):
391+
case let .resulted(.success(value)):
392392
lock.lock()
393393
defer { lock.unlock() }
394394
results.append(value)
395395
guard results.count == count else { return }
396-
zippedFuture.become(.resulted(with: .value(results)))
397-
case let .resulted(.error(reason)):
398-
zippedFuture.become(.resulted(with: .error(reason)))
396+
zippedFuture.become(.resulted(with: .success(results)))
397+
case let .resulted(.failure(reason)):
398+
zippedFuture.become(.resulted(with: .failure(reason)))
399399
case .canceled:
400400
zippedFuture.become(.canceled)
401401
case .waiting: break
@@ -417,9 +417,9 @@ public func future<T>(on worker: Worker = OperationQueue(), _ body: @escaping ()
417417
let future: Future<T> = .init(executionContext: .explicit(worker))
418418
worker.schedule {
419419
do {
420-
try future.become(.resulted(with: .value(body())))
420+
try future.become(.resulted(with: .success(body())))
421421
} catch {
422-
future.become(.resulted(with: .error(error)))
422+
future.become(.resulted(with: .failure(error)))
423423
}
424424
}
425425
return future

Sources/Futura/Future/Promise.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public final class Promise<Value> {
3636
/// transformations and handlers made on associated Future. Default is .undefined.
3737
public convenience init(succeededWith value: Value, executionContext: ExecutionContext = .undefined) {
3838
self.init(executionContext: executionContext)
39-
future.become(.resulted(with: .value(value)))
39+
future.become(.resulted(with: .success(value)))
4040
}
4141

4242
/// Creates already finished Promise with given error and context.
@@ -46,21 +46,21 @@ public final class Promise<Value> {
4646
/// transformations and handlers made on associated Future. Default is .undefined.
4747
public convenience init(failedWith error: Error, executionContext: ExecutionContext = .undefined) {
4848
self.init(executionContext: executionContext)
49-
future.become(.resulted(with: .error(error)))
49+
future.become(.resulted(with: .failure(error)))
5050
}
5151

5252
/// Finish Promise with given value. It will be ignored when already finished.
5353
///
5454
/// - Parameter value: Value finishing this Promise.
5555
public func fulfill(with value: Value) {
56-
future.become(.resulted(with: .value(value)))
56+
future.become(.resulted(with: .success(value)))
5757
}
5858

5959
/// Finish Promise with given error. It will be ignored when already finished.
6060
///
6161
/// - Parameter error: Error completing this Promise.
6262
public func `break`(with error: Error) {
63-
future.become(.resulted(with: .error(error)))
63+
future.become(.resulted(with: .failure(error)))
6464
}
6565

6666
/// Finish Promise without value or error. It will be ignored when already finished.

Sources/Futura/Result.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

Sources/Futura/Signal/Emitter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public final class Emitter<Value>: Signal<Value> {
2626
///
2727
/// - Parameter value: The value that will be broadcasted from this emitter.
2828
public func emit(_ value: Value) {
29-
broadcast(.value(value))
29+
broadcast(.success(value))
3030
}
3131

3232
/// Broadcasts given error to all subscriptions.
3333
/// This method have no effect on Emitter that have finished.
3434
///
3535
/// - Parameter error: The error that will be broadcasted from this emitter.
3636
public func emit(_ error: Error) {
37-
broadcast(.error(error))
37+
broadcast(.failure(error))
3838
}
3939

4040
/// Finishes this Emitter and all associated Signals.

0 commit comments

Comments
 (0)