Skip to content

Commit d1b6834

Browse files
committed
[Style] reorganize combine logic from SHFirestoreHelpers.swift to Combine+Helpers
1 parent ca1de5b commit d1b6834

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

Sources/SHFirestoreService/Combine+FutureHelpers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import Foundation
1010
#if canImport(Combine) && os(iOS) && swift(>=5.0)
1111
import Combine
1212

13+
@available(swift 5.0)
14+
@available(iOS 13.0, *)
15+
1316
public extension Publisher
1417
where Output == Void, Failure == FirestoreServiceError {
1518
func sink(promise: @escaping Future<Output, Error>.Promise) -> AnyCancellable {

Sources/SHFirestoreService/Combine+Helpers.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@ import Foundation
1010
#if canImport(Combine) && os(iOS) && swift(>=5.0)
1111
import Combine
1212

13+
@available(swift 5.0)
14+
@available(iOS 13.0, *)
15+
1316
internal extension Publisher {
1417
func subscribeAndReceive(
1518
on queue: DispatchQueue
1619
) -> Publishers.ReceiveOn<Publishers.SubscribeOn<Self, DispatchQueue>, DispatchQueue> {
1720
return self.subscribe(on: queue).receive(on: queue)
1821
}
1922
}
23+
24+
internal extension Publisher where Failure == Error {
25+
func convertFirestoreServiceError(
26+
) -> Publishers.MapError<Self, FirestoreServiceError> {
27+
return self.mapError { error in
28+
FirestoreServiceError.wrappedfirestoreError(error)
29+
}
30+
}
31+
}
32+
2033
#endif

Sources/SHFirestoreService/SHFirestoreHelpers.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55
// Created by 양승현 on 4/24/24.
66
//
77

8+
#if os(iOS) && swift(>=5.0)
89
import Foundation
9-
import Combine
1010

11-
internal extension Publisher where Failure == Error {
12-
func convertFirestoreServiceError(
13-
) -> Publishers.MapError<Self, FirestoreServiceError> {
14-
return self.mapError { error in
15-
FirestoreServiceError.wrappedfirestoreError(error)
16-
}
17-
}
18-
}
11+
@available(swift 5.0)
12+
@available(iOS 13.0, *)
1913

2014
internal extension Encodable {
21-
func toDictionary() throws -> [String: Any] {
15+
typealias Dictionary = [String: Any]
16+
func toDictionary() throws -> Dictionary {
2217
let data = try JSONEncoder().encode(self)
23-
guard let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any] else {
18+
guard let dict = try JSONSerialization.jsonObject(with: data) as? Dictionary else {
2419
throw Swift.EncodingError.invalidValue(
2520
self,
2621
Swift.EncodingError.Context.init(
@@ -30,3 +25,5 @@ internal extension Encodable {
3025
return dict
3126
}
3227
}
28+
29+
#endif

0 commit comments

Comments
 (0)