Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Commit 58e4375

Browse files
author
ivanlisovyi
committed
Replace OpenCombine with Combine
1 parent e147a80 commit 58e4375

File tree

72 files changed

+85
-112
lines changed

Some content is hidden

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

72 files changed

+85
-112
lines changed

Example/CarlosMacSample/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Cocoa
22
import Carlos
3-
import OpenCombine
3+
import Combine
44

55
@NSApplicationMain
66
class AppDelegate: NSObject, NSApplicationDelegate {

Example/CarlosWatchSample Extension/InterfaceController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import WatchKit
22
import Foundation
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
private struct Country {
88
let name: String

Example/Example/ComplexCacheSampleViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
struct ModelDomain {
88
let name: String
@@ -94,7 +94,7 @@ class ComplexCacheSampleViewController: BaseCacheViewController {
9494
let key = ModelDomain(name: nameField.text ?? "", identifier: Int(identifierField.text ?? "") ?? 0, URL: URL(string: urlField.text ?? "")!)
9595

9696
cache.get(key)
97-
.subscribe(on: DispatchQueue(label: "carlose test queu", qos: .userInitiated).ocombine)
97+
.subscribe(on: DispatchQueue(label: "carlose test queu", qos: .userInitiated))
9898
.sink(receiveCompletion: { _ in }) { data in
9999
print(data)
100100
}.store(in: &cancellables)

Example/Example/ConditionedCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
enum ConditionError: Error {
88
case globalKillSwitch
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Foundation
22

33
import Carlos
4-
import OpenCombine
4+
import Combine
55

66
final class DelayedNetworkFetcher: NetworkFetcher {
77
override func get(_ key: KeyType) -> AnyPublisher<OutputType, Error> {
88
super.get(key)
9-
.delay(for: 2, scheduler: DispatchQueue.global().ocombine)
9+
.delay(for: 2, scheduler: DispatchQueue.global())
1010
.eraseToAnyPublisher()
1111
}
1212
}

Example/Example/ImageCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
final class ImageCacheSampleViewController: BaseCacheViewController {
88
private var cache: BasicCache<URL, UIImage>!

Example/Example/JSONCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
private var myContext = 0
88

Example/Example/PooledCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
final class PooledCacheSampleViewController: BaseCacheViewController {
88
private var cache: PoolCache<BasicCache<URL, NSData>>!

Example/Example/SwitchCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
final class SwitchCacheSampleViewController: BaseCacheViewController {
88
private var cache: BasicCache<URL, NSData>!

Example/Example/UserDefaultsCacheSampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import UIKit
33

44
import Carlos
5-
import OpenCombine
5+
import Combine
66

77
final class UserDefaultsCacheSampleViewController: BaseCacheViewController {
88
private var cache: NSUserDefaultsCacheLevel<String, NSData>!

Package.resolved

-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
"version": "8.1.1"
1111
}
1212
},
13-
{
14-
"package": "OpenCombine",
15-
"repositoryURL": "https://github.com/OpenCombine/OpenCombine.git",
16-
"state": {
17-
"branch": null,
18-
"revision": "f3d068d6f2090d2913c9e1b75cc36cef962a530c",
19-
"version": "0.10.0"
20-
}
21-
},
2213
{
2314
"package": "Quick",
2415
"repositoryURL": "https://github.com/Quick/Quick.git",

Package.swift

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import PackageDescription
55
let package = Package(
66
name: "Carlos",
77
platforms: [
8-
.iOS(.v12),
8+
.iOS(.v13),
99
.macOS(.v10_15),
10-
.tvOS(.v12),
10+
.tvOS(.v13),
1111
.watchOS(.v5)
1212
],
1313
products: [
@@ -16,18 +16,13 @@ let package = Package(
1616
targets: ["Carlos"]),
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.10.0"),
2019
.package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "3.0.0")),
2120
.package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.1.0")),
2221
],
2322
targets: [
2423
.target(
2524
name: "Carlos",
26-
dependencies: [
27-
"OpenCombine",
28-
.product(name: "OpenCombineDispatch", package: "OpenCombine"),
29-
.product(name: "OpenCombineFoundation", package: "OpenCombine")
30-
]
25+
dependencies: []
3126
),
3227
.testTarget(
3328
name: "CarlosTests",

Sources/Carlos/BasicCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// A wrapper cache that explicitly takes get, set, clear and memory warning closures
55
public final class BasicCache<A, B>: CacheLevel {

Sources/Carlos/BasicFetcher.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// A wrapper fetcher that explicitly takes a get closure
55
public final class BasicFetcher<A, B>: Fetcher {

Sources/Carlos/BatchAllCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import OpenCombine
1+
import Combine
22

33
/// A reified batchGetAll
44
public final class BatchAllCache<KeySeq: Sequence, Cache: CacheLevel>: CacheLevel where KeySeq.Iterator.Element == Cache.KeyType {

Sources/Carlos/CacheLevel+Batch.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55
/**

Sources/Carlos/Carlos.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
public struct CarlosGlobals {
55
public static let queueNamePrefix = "com.carlos."

Sources/Carlos/Composed.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55
/**

Sources/Carlos/ComposedTwoWayTransformer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension TwoWayTransformer {
55
/**

Sources/Carlos/Conditioned.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55

Sources/Carlos/ConditionedOneWayTransformer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// Abstract an object that can conditionally transform values to another type
55
public protocol ConditionedOneWayTransformer {

Sources/Carlos/ConditionedOutputProcessing.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55

Sources/Carlos/ConditionedTwoWayTransformer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// Abstract an object that can conditionally transform values to another type and back to the original one, based on a given key
55
public protocol ConditionedTwoWayTransformer: ConditionedOneWayTransformer {

Sources/Carlos/ConditionedValueTransformation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55

Sources/Carlos/DiskCacheLevel.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22

3-
import OpenCombine
4-
import OpenCombineDispatch
3+
import Combine
54

65
public enum DiskCacheLevelError: Error {
76
case diskArchiveWriteFailed
@@ -68,7 +67,7 @@ public final class DiskCacheLevel<K: StringConvertible, T: NSCoding>: CacheLevel
6867

6968
return Just((value, key))
7069
.setFailureType(to: Error.self)
71-
.receive(on: cacheQueue.ocombine)
70+
.receive(on: cacheQueue)
7271
.flatMap(setDataSync)
7372
.eraseToAnyPublisher()
7473
}

Sources/Carlos/Extensions.swift

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
import Foundation
2+
import CryptoKit
23
import CommonCrypto
3-
import OpenCombine
4+
import Combine
45

56
public extension String {
6-
func MD5Data() -> Data? {
7-
let data = Data(self.utf8)
8-
let hash = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> [UInt8] in
9-
var hash = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH))
10-
CC_MD5(bytes.baseAddress, CC_LONG(data.count), &hash)
11-
return hash
12-
}
13-
14-
return Data(bytes: hash, count: hash.count)
15-
}
16-
177
func MD5String() -> String {
18-
guard let md5Data = MD5Data() else {
8+
guard let data = data(using: .utf8) else {
199
return self
2010
}
21-
return String(data: md5Data, encoding: .utf8) ?? self
11+
12+
return Insecure.MD5.hash(data: data).map { String(format: "%02hhx", $0) }.joined()
2213
}
2314
}
2415

@@ -27,7 +18,7 @@ extension DispatchQueue {
2718
Future<Output, Failure> { promise in
2819
self.async { block(promise) }
2920
}
30-
.receive(on: DispatchQueue.main.ocombine)
21+
.receive(on: DispatchQueue.main)
3122
.eraseToAnyPublisher()
3223
}
3324
}

Sources/Carlos/FunctionComposition.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
infix operator >>>: CompositionPrecedence
55
precedencegroup CompositionPrecedence {

Sources/Carlos/ImageTransformer.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22

3-
import OpenCombine
4-
import OpenCombineDispatch
3+
import Combine
54

65
#if os(macOS)
76
import Cocoa
@@ -42,7 +41,7 @@ public final class ImageTransformer: TwoWayTransformer {
4241
promise(.failure(TransformationError.invalidData))
4342
}
4443
}
45-
.receive(on: DispatchQueue.main.ocombine)
44+
.receive(on: DispatchQueue.main)
4645
.eraseToAnyPublisher()
4746
}
4847

@@ -73,7 +72,7 @@ public final class ImageTransformer: TwoWayTransformer {
7372
.setFailureType(to: Error.self)
7473
.eraseToAnyPublisher()
7574
}
76-
.receive(on: DispatchQueue.main.ocombine)
75+
.receive(on: DispatchQueue.main)
7776
.eraseToAnyPublisher()
7877
}
7978
}

Sources/Carlos/JSONTransformer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/**
55
This class takes care of transforming NSData instances into JSON objects in the form of AnyObject instances. Depending on your usage, the AnyObject could contain an Array, a Dictionary, or nil if the NSData is not a valid JSON

Sources/Carlos/KeyTransformation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel {
55
/**

Sources/Carlos/MemoryCacheLevel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// This class is a memory cache level. It internally uses NSCache, and has a configurable total cost limit that defaults to 50 MB.
55
public final class MemoryCacheLevel<K: StringConvertible, T: AnyObject>: CacheLevel where T: ExpensiveObject {

Sources/Carlos/NSUserDefaultsCacheLevel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/**
55
Default name for the persistent domain used by the NSUserDefaultsCacheLevel

Sources/Carlos/NetworkFetcher.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22

3-
import OpenCombine
4-
import OpenCombineDispatch
5-
import OpenCombineFoundation
3+
import Combine
64

75
public enum NetworkFetcherError: Error {
86
/// Used when the status code of the network response is not included in the range 200..<300
@@ -35,7 +33,7 @@ open class NetworkFetcher: Fetcher {
3533
}
3634

3735
private func startRequest(_ URL: Foundation.URL) -> AnyPublisher<NSData, Error> {
38-
URLSession.shared.ocombine.dataTaskPublisher(for: URL)
36+
URLSession.shared.dataTaskPublisher(for: URL)
3937
.tryMap { (data, response) -> NSData in
4038
guard let response = response as? HTTPURLResponse else {
4139
throw NetworkFetcherError.invalidNetworkResponse
@@ -69,7 +67,7 @@ open class NetworkFetcher: Fetcher {
6967
*/
7068
open func get(_ key: KeyType) -> AnyPublisher<OutputType, Error> {
7169
startRequest(key)
72-
.receive(on: DispatchQueue.main.ocombine)
70+
.receive(on: DispatchQueue.main)
7371
.eraseToAnyPublisher()
7472
}
7573
}

Sources/Carlos/OneWayTransformer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
/// Abstract an object that can transform values to another type
55
public protocol OneWayTransformer {

Sources/Carlos/PoolCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import OpenCombine
2+
import Combine
33

44
extension CacheLevel where KeyType: Hashable {
55

0 commit comments

Comments
 (0)