Implement Flatten and Chained 🚀
Chained requests
Now you're able to run up to 10 requests one-by-one!
API.employee.all()
.and(API.office.all())
.and(API.car.all())
.and(API.event.all())
.and(API.post.all())
.onError { error in
print(error.description)
}.onSuccess { employees, offices, cars, events, posts in
// do what you want with received results!!! 🍻
}
onRequestStarted, onNetworkUnavailable, onCancellation, onNotAuthorized, onTimeout also available!
//TBD: onProgress
It is awesome! Especially for whom who not familiar or don't like reactive programming 🙂
Flatten
And if you want to run several requests one-by-one or concurrently but with just completion handler you also can do that with .flatten()
[API.employee.all(), API.office.all(), API.car.all()].flatten().onError {
print(error.description)
}.onSuccess {
print("flatten finished!")
}
to run them concurrently just add .concurrent(by: 3)
to run by 3 at the same time
to skip errors also add .avoidCancelOnError()
to get progress add .onProgress
Hope it's cool! 😎
Please let me know in issues if you need any improvements or bug fixes.