Skip to content

Commit 9f4acd1

Browse files
gh-action-runnergh-action-runner
authored andcommitted
Squashed 'apollo-ios-pagination/' changes from 73ec3fd3..6228198e
6228198e [ApolloPagination] Add conditional conformance to pagers (#298) git-subtree-dir: apollo-ios-pagination git-subtree-split: 6228198eb49b4506c169b0852a1a07cefbc1f75d
1 parent fb10e20 commit 9f4acd1

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Sources/ApolloPagination/AsyncGraphQLQueryPager.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,21 @@ public class AsyncGraphQLQueryPager<Model>: Publisher {
245245
publisher.subscribe(subscriber)
246246
}
247247
}
248+
249+
extension AsyncGraphQLQueryPager: Equatable where Model: Equatable {
250+
public static func == (lhs: AsyncGraphQLQueryPager<Model>, rhs: AsyncGraphQLQueryPager<Model>) -> Bool {
251+
let left = lhs._subject.value
252+
let right = rhs._subject.value
253+
254+
switch (left, right) {
255+
case (.success((let leftValue, let leftSource)), .success((let rightValue, let rightSource))):
256+
return leftValue == rightValue && leftSource == rightSource
257+
case (.failure(let leftError), .failure(let rightError)):
258+
return leftError.localizedDescription == rightError.localizedDescription
259+
case (.none, .none):
260+
return true
261+
default:
262+
return false
263+
}
264+
}
265+
}

Sources/ApolloPagination/GraphQLQueryPager.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,21 @@ public class GraphQLQueryPager<Model>: Publisher {
249249
publisher.subscribe(subscriber)
250250
}
251251
}
252+
253+
extension GraphQLQueryPager: Equatable where Model: Equatable {
254+
public static func == (lhs: GraphQLQueryPager<Model>, rhs: GraphQLQueryPager<Model>) -> Bool {
255+
let left = lhs._subject.value
256+
let right = rhs._subject.value
257+
258+
switch (left, right) {
259+
case (.success((let leftValue, let leftSource)), .success((let rightValue, let rightSource))):
260+
return leftValue == rightValue && leftSource == rightSource
261+
case (.failure(let leftError), .failure(let rightError)):
262+
return leftError.localizedDescription == rightError.localizedDescription
263+
case (.none, .none):
264+
return true
265+
default:
266+
return false
267+
}
268+
}
269+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
public enum UpdateSource {
1+
public enum UpdateSource: Hashable {
22
case fetch, cache
33
}

0 commit comments

Comments
 (0)