Created
June 8, 2023 04:41
-
-
Save u0705666/67fc187e4983d658794b3b25d86e65f5 to your computer and use it in GitHub Desktop.
suspend api single call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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