Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active May 7, 2019 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/84437c0ca99e149d69981998075dcb7b to your computer and use it in GitHub Desktop.
Save hlung/84437c0ca99e149d69981998075dcb7b to your computer and use it in GitHub Desktop.
import Foundation
protocol Pageable {
/// Moves the receiver's value to next set
mutating func next(cursor: String?)
}
// Represents a paged response from API.
protocol PagedResponse {
associatedtype Element
var elements: [Element] { get }
var pageInfo: PageInfo { get }
}
struct PageInfo: Decodable {
let hasNextPage: Bool
let nextCursor: String?
init() {
self.hasNextPage = false
self.nextCursor = nil
}
init(hasNextPage: Bool, nextCursor: String?) {
self.hasNextPage = hasNextPage
self.nextCursor = nextCursor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment