Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2023 04:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
concurrent suspend api calls
@Inject lateinit var suspendApi: SuspendApi
shownScope.launch {
val assetCategoriesResultDeferred = async{suspendApi.getAssetCategories()}
val categorizedAssetDeferred = async{suspendApi.getCategorizedAssets()}
val assetCategoriesResult = assetCategoriesResultDeferred.await()
val categorizedAssetsResult = categorizedAssetDeferred.await()
if (assetCategoriesResult is ApiResult.Success && categorizedAssetsResult is ApiResult.Success) {
assetCategoryList =
fullAssetList =
view!!.setupCategoryView(getCategoryListItem(assetCategoryList!!, fullAssetList!!))
} else {
toaster.showShortErrorToast("api error to get category or assets list")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment