-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Werner Altewischer
committed
Nov 11, 2019
1 parent
bc3d765
commit e41da3f
Showing
17 changed files
with
134 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
import ReactiveSwift | ||
|
||
public protocol Cache { | ||
associatedtype Key: Hashable | ||
associatedtype Value | ||
subscript(_ key: Key) -> Value? { get set } | ||
} | ||
|
||
extension Dictionary: Cache { | ||
|
||
} | ||
|
||
extension Atomic where Value: Cache { | ||
public subscript(_ key: Value.Key) -> Value.Value? { | ||
get { | ||
return self.withValue { map -> Value.Value? in | ||
return map[key] | ||
} | ||
} | ||
|
||
set { | ||
self.modify { map in | ||
map[key] = newValue | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Foundation | ||
|
||
/// An error originating from ReactiveTask. | ||
public enum TaskError: Error, Equatable { | ||
|
||
/// A shell task failed to launch | ||
case launchFailed(Task, reason: String?) | ||
|
||
/// A shell task exited unsuccessfully. | ||
case shellTaskFailed(Task, exitCode: Int32, standardError: String?) | ||
|
||
/// An error was returned from a POSIX API. | ||
case posixError(Int32) | ||
} | ||
|
||
extension TaskError: CustomStringConvertible { | ||
public var description: String { | ||
switch self { | ||
case let .launchFailed(task, reason: reason): | ||
var description = "A shell task (\(task)) failed to launch" | ||
if let reason = reason { | ||
description += ":\n\(reason)" | ||
} | ||
return description | ||
|
||
case let .shellTaskFailed(task, exitCode, standardError): | ||
var description = "A shell task (\(task)) failed with exit code \(exitCode)" | ||
if let standardError = standardError { | ||
description += ":\n\(standardError)" | ||
} | ||
return description | ||
|
||
case let .posixError(code): | ||
return NSError(domain: NSPOSIXErrorDomain, code: Int(code), userInfo: nil).description | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.