Skip to content

Instantly share code, notes, and snippets.

@u0705666
Created June 8, 2023 04:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u0705666/67fc187e4983d658794b3b25d86e65f5 to your computer and use it in GitHub Desktop.
Save u0705666/67fc187e4983d658794b3b25d86e65f5 to your computer and use it in GitHub Desktop.
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