Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HIFILEO/73d4d286f2f3952c12cb52a5034e3087 to your computer and use it in GitHub Desktop.
Save HIFILEO/73d4d286f2f3952c12cb52a5034e3087 to your computer and use it in GitHub Desktop.
uiModelObservable = publishRelayUiEvents
.observeOn(Schedulers.computation())
//Translate UiEvents into Actions
.compose(transformEventsIntoActions)
//Asynchronous Actions To Interactor
.publish(actionObservable -> nowPlayingInteractor.processAction(actionObservable))
//Scan Results to Update UiModel
.scan(initialUiModel, (uiModel, result) -> {
if (result instanceof ScrollResult) {
return processScrollResult(uiModel, (ScrollResult) result);
} else if (result instanceof ***) {
return processRestoreResult(uiModel, (***) result);
}
throw new IllegalArgumentException("Unknown Result: " + result);
})
//Publish results to main thread.
.observeOn(AndroidSchedulers.mainThread())
//Save history for late subscribers.
.replay(1)
.autoConnect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment