Replies: 2 comments 2 replies
func get(page: Int? = 0) -> Promise<SomeResponse> {
//…
}
func getAll() -> Promise<[Page]> {
return get().then { rsp -> Promise<[Page]> in
if rsp.hasAnotherPage {
return get(page: nextPage).map {
rsp.pages + $0.pages
}
} else {
return results
}
}
} |
2 replies
private func fetch(page: Int) -> Promise<SomeResponse> {
//…
}
func get(page: Int = 0) -> Promise<[Page]> {
return fetch(page: page).then { rsp in
if rsp.hasAnotherPage {
return get(page: page + 1).map {
rsp.pages + $0.pages
}
} else {
return Promise(value: rsp.results)
}
}
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, i've a common scenario with PromiseKit but I'm unable to figure out the best approach.
I want to retrieve some data from a website, but those data are dispatched on several pages. In some case there's only 1 page but it maybe 2, 3, 4, ... pages.
My code is below :
Is there someone able to give me a solution to solve this problem ?
All reactions