Skip to content

Instantly share code, notes, and snippets.

@u0705666
Created June 8, 2023 04:39
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/38ee8ee5575ae4cf207e06057e6867cd to your computer and use it in GitHub Desktop.
Save u0705666/38ee8ee5575ae4cf207e06057e6867cd to your computer and use it in GitHub Desktop.
rxjava-combined-api-call-example
private fun fetchAccounts() {
val externalAccountLinkStatusObservable = linkCoordinator.linkStatusObservable
val wealthFrontAccountObservable = accountRepository.wealthfrontAccountObservable
val wealthFrontAccountRequestsObservable = accountRequestsRepository.wealthfrontAccountRequestObservable
val calloutObservable = calloutsRepository.getCalloutsObservable(AccountListSection::class.java)
autoDisposer.autoDispose(
combineLatest(
externalAccountLinkStatusObservable,
wealthFrontAccountObservable,
wealthFrontAccountRequestsObservable,
calloutObservable
) { parallelLinkingResult, abstractAccountOverviews, accountRequests, callouts ->
showAccounts(abstractAccountOverviews, accountRequests, parallelLinkingResult.statuses, callouts)
}
.doOnSubscribe { view?.showTransparentLoading() }
.subscribe(
{
view?.hideLoadingAndErrorStates()
},
{
view?.hideLoadingAndErrorStates()
networkErrorToaster.showErrorMessage(it, R.string.dashboard_load_error)
}
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment