Skip to content

Pagination offsets #239

Answered by sbertix
ramimoghrabi asked this question in Q&A
Jun 28, 2021 · 4 comments · 21 replies
Discussion options

You must be logged in to vote

Hey @ramimoghrabi,

Let's assume, for simplicity, you're fetching the first page of followers like this.

let secret: Secret = /* a valid `Secret` */
var bin: Set<AnyCancellable> = /* a **retained** `Set` */

Endpoint.user(secret.identifier)
   .followers
   .unlock(with: secret)
   .session(.instagram)
   .pages(1)
   .catch { _ in Empty() }
   .sink {
      // Do whatever you need to do with your response here…

      guard let nextOffset = $0.offset else { return }
      // If next offset is non-`nil`, you can just cache it or
      // persist it somewhere.
   }
   .store(in: &bin)

Now assuming you saved nextOffset somewhere, when you need to load the second page of followers, you can ju…

Replies: 4 comments 21 replies

Comment options

You must be logged in to vote
12 replies
@sbertix
Comment options

@diligiant
Comment options

@sbertix
Comment options

@diligiant
Comment options

@sbertix
Comment options

Answer selected by sbertix
Comment options

You must be logged in to vote
2 replies
@sbertix
Comment options

@ramimoghrabi
Comment options

Comment options

You must be logged in to vote
7 replies
@sbertix
Comment options

@ramimoghrabi
Comment options

@ramimoghrabi
Comment options

@sbertix
Comment options

@ramimoghrabi
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants