I would like to make async query while last query returns nil. How to chain something like that? I can't create an array before, since I don't know how many chaining loops I will have.
func bar() -> Promise<T?> {
//…
}
func baz() -> Promise<T> {
return bar().then {
if let done = value {
return Promise(value: done)
} else {
return baz()
}
}
}
baz().then { value in
// all done
}
This just came in super hand for paged network.
Most helpful comment