Skip to content

Commit dad927d

Browse files
committed
[Feat] Improved request function array return type
1 parent 1c8b6e5 commit dad927d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Sources/SHFirestoreService/FirestoreService.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ extension FirestoreService: FirestoreServiceProtocol {
3333
public func request<D, E>(
3434
endpoint: E
3535
) -> AnyPublisher<[D], FirestoreServiceError>
36-
where D == E.ResponseDTO, E : FirestoreEndopintable {
36+
where E: FirestoreEndopintable,
37+
E.ResponseDTO: Collection,
38+
E.ResponseDTO.Element == D,
39+
D: Decodable {
3740
guard let collectionRef = endpoint.reference as? CollectionReference else {
3841
return Fail(error: FirestoreServiceError.collectionNotFound).eraseToAnyPublisher()
3942
}
@@ -217,7 +220,7 @@ extension FirestoreService: FirestoreServiceProtocol {
217220
public func retrieveDocumentIDs<E>(
218221
endpoint: E
219222
) -> AnyPublisher<E.ResponseDTO, FirestoreServiceError>
220-
where E : FirestoreEndopintable, E.ResponseDTO == [String] {
223+
where E: FirestoreEndopintable, E.ResponseDTO == [String] {
221224
guard case .retrieveDocumentIdList = endpoint.method else {
222225
return Fail(error: FirestoreServiceError.invalidFirestoreMethodRequest).eraseToAnyPublisher()
223226
}

Sources/SHFirestoreService/FirestoreServiceProtocol.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ public protocol FirestoreServiceProtocol: FirestoreTransactional, FirestoreQuery
1515

1616
// MARK: - Helpers
1717
func request<D, E>(endpoint: E) -> AnyPublisher<[D], FirestoreServiceError>
18-
where D: Decodable,
19-
E: FirestoreEndopintable,
20-
D == E.ResponseDTO
18+
where E: FirestoreEndopintable,
19+
E.ResponseDTO: Collection,
20+
E.ResponseDTO.Element == D,
21+
D: Decodable
2122

2223
func request<D, E>(endpoint: E) -> AnyPublisher<D, FirestoreServiceError>
2324
where D: Decodable,

0 commit comments

Comments
 (0)