Skip to content

Commit

Permalink
Merge pull request #76 from TheInkedEngineer/fix/Xcode12-compatibilit…
Browse files Browse the repository at this point in the history
…y-2.0.2

[Fix] Xcode 12 compatibility + typos
  • Loading branch information
malcommac authored Jul 23, 2020
2 parents 0df04a9 + 65ffa58 commit 95cbf79
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 16 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "8543AB78-D45C-4EF9-B6DC-39F8F011741C"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>DemoApp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
</dict>
<key>Hydra-iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>Hydra-macOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Hydra-tvOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Hydra-watchOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Sources/Hydra/Commons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public enum PromiseError: Error {


/// Invalidatable protocol is used to control the execution of a promise from the outside
/// You should pass an object conforms to this type at the init of your Promsie instance.
/// You should pass an object conforms to this type at the init of your Promise instance.
/// To invalidate a Promise just return the `.isCancelled` property to `true`.
///
/// From the inside of your Promise's body you should check if the `operation.isCancelled` is `true`.
Expand All @@ -67,7 +67,7 @@ public protocol InvalidatableProtocol {


/// This is a simple implementation of the `InvalidatableProtocol` protocol.
/// You can use or extend this class in order to provide your own bussiness logic.
/// You can use or extend this class in order to provide your own business logic.
open class InvalidationToken: InvalidatableProtocol {

/// Current status of the promise
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hydra/DispatchTimerWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal class DispatchTimerWrapper {
timer.setEventHandler(handler: handler)
}

func scheduleOneshot(deadline: DispatchTime, leeway: DispatchTimeInterval = .nanoseconds(0)) {
func scheduleOneShot(deadline: DispatchTime, leeway: DispatchTimeInterval = .nanoseconds(0)) {
timer.schedule(deadline: deadline, leeway: leeway)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Hydra/Promise+All.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public func all<L, S: Sequence>(_ promises: S, concurrency: UInt = UInt.max) ->
}

// We want to create a Promise which groups all input Promises and return only
// when all input promises fullfill or one of them reject.
// when all input promises fulfill or one of them reject.
// Promises are resolved in parallel but the array with the results of all promises is reported
// in the same order of the input promises.
let allPromise = Promise<[L]> { (resolve, reject, operation) in
Expand All @@ -66,7 +66,7 @@ public func all<L, S: Sequence>(_ promises: S, concurrency: UInt = UInt.max) ->
// decrement remaining promise to fulfill
countRemaining -= 1
if countRemaining == 0 {
// if all promises are fullfilled we can resolve our chain Promise
// if all promises are fulfilled we can resolve our chain Promise
// with an array of all values results of our input promises (in the same order)
let allResults = promises.map({ return $0.state.value! })
resolve(allResults)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Hydra/Promise+Await.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public prefix func ..!<T> (_ promise: Promise<T>) -> T? {
/// - Parameters:
/// - context: context in which you want to execute the operation. If not specified default concurrent `awaitContext` is used instead.
/// - promise: target promise
/// - Returns: fufilled value of the promise
/// - Returns: fulfilled value of the promise
/// - Throws: throws an exception if promise fails due to an error
@discardableResult
public func await<T>(in context: Context? = nil, _ promise: Promise<T>) throws -> T {
Expand Down Expand Up @@ -111,16 +111,16 @@ public extension Context {
let semaphore = DispatchSemaphore(value: 0)

promise.then(in: self) { value -> Void in
// promise is fulfilled, fillup error and resume code execution
// promise is fulfilled, fill-up error and resume code execution
result = value
semaphore.signal()
}.catch(in: self) { err in
// promise is rejected, fillup error and resume code execution
// promise is rejected, fill-up error and resume code execution
error = err
semaphore.signal()
}

// Wait and block code execution until promise is fullfilled or rejected
// Wait and block code execution until promise is full-filled or rejected
_ = semaphore.wait(timeout: .distantFuture)

guard let promiseValue = result else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hydra/Promise+Cancel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public extension Promise {
/// Catch a cancelled promise.
///
/// - Parameters:
/// - context: context in which the body will be eecuted. If not specified `.main` is used.
/// - context: context in which the body will be executed. If not specified `.main` is used.
/// - body: body to execute
/// - Returns: a new void promise
@discardableResult
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hydra/Promise+Defer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Foundation

public extension Promise {

/// Delay the executon of a Promise chain by some number of seconds from current time
/// Delay the execution of a Promise chain by some number of seconds from current time
///
/// - Parameters:
/// - context: context in which the body is executed (if not specified `background` is used)
Expand Down
5 changes: 2 additions & 3 deletions Sources/Hydra/Promise+Recover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import Foundation

public extension Promise {

/// Allows you to recover a failed promise by returning another promise with the same output
///
/// - Parameters:
Expand All @@ -43,8 +42,8 @@ public extension Promise {
/// - Returns: a promise
func recover(in context: Context? = nil, _ body: @escaping (Error) throws -> Promise<Value>) -> Promise<Value> {
let ctx = context ?? .background
return Promise<Value>(in: ctx, token: self.invalidationToken, { resolve, reject, operation in
return self.then(in: ctx, {
return Promise<Value>(in: ctx, token: self.invalidationToken, { [weak self] resolve, reject, operation in
self?.then(in: ctx, {
// If promise resolve we don't need to do anything.
resolve($0)
}).catch(in: ctx, { error in
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hydra/Promise+Timeout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public extension Promise {
let errorToPass = (error ?? PromiseError.timeout)
reject(errorToPass)
}
timer.scheduleOneshot(deadline: .now() + timeout)
timer.scheduleOneShot(deadline: .now() + timeout)
timer.resume()

// Observe resolve
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hydra/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class Promise<Value> {
/// ```
/// let op_1: Promise<User> = asyncGetCurrentUserProfile()
/// let op_2: Promise<UIImage> = asyncGetCurrentUserAvatar()
/// let op_3: Promise<[User]> = asyncGetCUrrentUserFriends()
/// let op_3: Promise<[User]> = asyncGetCurrentUserFriends()
/// all(op_1.void,op_2.void,op_3.void).then { _ in
/// let userProfile = op_1.result
/// let avatar = op_2.result
Expand Down

0 comments on commit 95cbf79

Please sign in to comment.