Last active
May 7, 2019 09:48
-
-
Save hlung/84437c0ca99e149d69981998075dcb7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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