var responseMap = mutableMapOf<VendorType, ChargeResponse>()
requests.forEach {
val response = when (it.vendorType) {
VendorType.Type1 -> service.chargeForType1()
VendorType.Type2 -> service.chargeForType2()
else -> {
throw NotImplementedError("${it.vendorType} does not support yet")
}
}
responseMap[it.vendorType] = response
}
responseMap
Поэтому я хочу, чтобы все функции service.charge
выполнялись в отдельном потоке. Верните карту, когда все будет сделано
service.charge
длинным вычислением или это получение чего-то из сети? - person Tenfour04   schedule 18.08.2020suspend
, либо принимают обратный вызов. Есть ли библиотека, с которой вы работаете? - person Tenfour04   schedule 18.08.2020