-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async operations and pagination completion #50
Conversation
dc83ef5
to
fe9b299
Compare
FetchRequests/Sources/Controller/FetchedResultsControllerProtocol.swift
Outdated
Show resolved
Hide resolved
performOnMainThread { | ||
self?.manuallyInsert(objects: pageResults, emitChanges: true) | ||
} | ||
|
||
DispatchQueue.main.async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment along the lines of // force this to run on the _next_ run loop, at which point any debounced insertions should have happened
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And discussed offline that you could be cognizant of the debounced inserts flag and not use an async call if we're not debouncing.
d5ad2cf
to
3ee6795
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, looks good!
@@ -41,16 +41,29 @@ public class PaginatingFetchDefinition<FetchedObject: FetchableObject>: FetchDef | |||
private extension InternalFetchResultsControllerProtocol { | |||
@MainActor | |||
func performPagination( | |||
with paginationRequest: PaginatingFetchDefinition<FetchedObject>.PaginationRequest | |||
with paginationRequest: PaginatingFetchDefinition<FetchedObject>.PaginationRequest, | |||
debounceInsertsAndReloads: Bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Nit:
willDebounceInsertsAndReloads
with paginationRequest: PaginatingFetchDefinition<FetchedObject>.PaginationRequest | ||
with paginationRequest: PaginatingFetchDefinition<FetchedObject>.PaginationRequest, | ||
debounceInsertsAndReloads: Bool, | ||
completion: @escaping (_ hasPageResults: Bool) -> Void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also @MainActor
@@ -77,8 +90,21 @@ public class PaginatingFetchedResultsController< | |||
} | |||
|
|||
@MainActor | |||
public func performPagination() { | |||
performPagination(with: paginatingDefinition.paginationRequest) | |||
public func performPagination(completion: @escaping (_ hasPageResults: Bool) -> Void = { _ in }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also @MainActor
performPagination
, informing consumers if the page request returned results.