Skip to content

Instantly share code, notes, and snippets.

@u0705666
Created June 8, 2023 04:41
  • 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
Embed
What would you like to do?
suspend api single call
@Inject lateinit var suspendApi: SuspendApi
shownScope.launch {
view.showSearchLoading()
val result = suspendApi.getCategorizedAssetsSearch(searchStr, assetCategory?.categoryIdentifier)
view.hideSearchLoading()
when (result) {
is ApiResult.Success -> {
view.replaceListItems(getAssetListItem(result.data.categorizedAssets))
}
is ApiResult.Failure -> toaster.showShortErrorToast("api error ${result.code}")
is ApiResult.NetworkError -> toaster.showShortErrorToast("network error")
}.exhaustive
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment