Skip to content

Commit

Permalink
feat(endpoints): support delay between pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sbertix committed May 22, 2021
1 parent 86b032b commit 4e11b0d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Expand Up @@ -18,7 +18,7 @@ let package = Package(
.library(name: "SwiftagramCrypto",
targets: ["SwiftagramCrypto"])],
// Package dependencies.
dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.1.0")),
dependencies: [.package(url: "https://github.com/sbertix/ComposableRequest", .upToNextMinor(from: "5.2.1")),
.package(url: "https://github.com/sbertix/SwCrypt.git", .upToNextMinor(from: "5.1.0"))],
// All targets.
targets: [.target(name: "Swiftagram",
Expand Down
2 changes: 1 addition & 1 deletion Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift
Expand Up @@ -46,7 +46,7 @@ public extension Endpoint.Group.Recent {
// Persist the rank token.
let rank = pages.rank ?? UUID().uuidString
// Prepare the actual pager.
return Pager(pages.count, offset: pages.offset.offset) {
return Pager(pages.count, offset: pages.offset.offset, delay: pages.delay) {
Request.feed
.path(appending: "timeline/")
.header(appending: secret.header)
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftagramTests/EndpointTests.swift
Expand Up @@ -21,6 +21,7 @@ import AppKit
@testable import Swiftagram
@testable import SwiftagramCrypto

import ComposableRequest
import SwCrypt

/// The default delay.
Expand Down
9 changes: 6 additions & 3 deletions docs/README.md
Expand Up @@ -245,9 +245,12 @@ Endpoint.user(secret.identifier)
.posts
.unlock(with: secret)
.session(.instagram)
.pages(.max) // Exhaust all with `.max`
// or pass any `Int` to limit
// pages.
.pages(.max, delay: 1) // Exhaust all with `.max`
// or pass any `Int` to limit
// pages.
// You can omit `delay`, in that
// case pages will be fetched
// one immediately after the other.
.sink(receiveCompletion: { _ in }, receiveValue: { print($0) })
.store(in: &bin)
```
Expand Down

0 comments on commit 4e11b0d

Please sign in to comment.