Skip to content

Instantly share code, notes, and snippets.

@myungpyo
Created June 1, 2022 13:45
Show Gist options
  • Save myungpyo/8bca75f74095f99f0988e5ceff528634 to your computer and use it in GitHub Desktop.
Save myungpyo/8bca75f74095f99f0988e5ceff528634 to your computer and use it in GitHub Desktop.
fun fetchPrimaryInfo() = viewModelScope.launch {
val appInfoDeferred = async { fetchAppInfoUseCase().execute() }
val userInfoDeferred = async { fetchUserInfoUseCase().execute() }
runCatching {
PrimaryInfo(
appInfo = appInfoDeferred.await(),
userInfo = userInfoDeferred.await(),
)
}.onSuccess { primaryInfo ->
updatePrimaryInfo(primaryInfo)
}.onFailure { throwable ->
Timber.d("Failed to fetch primary info. $throwable")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment