E526 Add async operations and pagination completion by mattfaluotico · Pull Request #50 · square/FetchRequests · GitHub
[go: up one dir, main page]

Skip to content

Add async operations and pagination completion#50

Merged
lickel merged 7 commits intomainfrom
mfaluotico/perform-async
Apr 3, 2024
Merged

Add async operations and pagination completion#50
lickel merged 7 commits intomainfrom
mfaluotico/perform-async

Conversation

@mattfaluotico
Copy link
Contributor
@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
@mattfaluotico mattfaluotico force-pushed the mfaluotico/perform-async branch from dc83ef5 to fe9b299 Compare April 2, 2024 17:51
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 force-pushed the mfaluotico/perform-async branch from d5ad2cf to 3ee6795 Compare April 2, 2024 20:55
@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!

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

@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

8270
@lickel lickel merged commit 7b36ee5 into main Apr 3, 2024
@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

0