Reputation: 1421
I want have an array of objects which I want to loop over and send every object using a post request and CoroutineScope to server.
Upvotes: 0
Views: 3940
Reputation: 3079
You can use the following pattern:
In code, it'd look like this
myData.map { data ->
async {
callToServer(data)
}
}.map {
it.await()
}
This would run each callToServer in separate job concurrently.
Upvotes: 3