Skip to content
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

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

mattfaluotico
Copy link
Collaborator

@mattfaluotico mattfaluotico commented Apr 1, 2024

  • Add support for async fetching, returning when completion closure of closure based version would be called
  • Add completion callback to performPagination , informing consumers if the page request returned results.
  • Tests for check completion values

@mattfaluotico mattfaluotico changed the title Mfaluotico/perform async Add async operations and pagination completion Apr 2, 2024
performOnMainThread {
self?.manuallyInsert(objects: pageResults, emitChanges: true)
}

DispatchQueue.main.async {
Copy link
Collaborator

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

Copy link
Collaborator

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.

@mattfaluotico mattfaluotico marked this pull request as ready for review April 2, 2024 23:39
Copy link
Collaborator

@lickel lickel left a 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,
Copy link
Collaborator

@lickel lickel Apr 3, 2024

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
Copy link
Collaborator

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 }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @MainActor

@lickel lickel merged commit 7b36ee5 into main Apr 3, 2024
5 checks passed
@lickel lickel deleted the mfaluotico/perform-async branch April 3, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants