Created
April 14, 2017 15:48
-
-
Save benigumocom/612a80f4140afd8bda2eaecae0de8c5a to your computer and use it in GitHub Desktop.
Reactive State 2
This file contains hidden or 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
disposables.add(RxView.clicks(submitView) | |
.map(ignored -> new SubmitEvent(nameView.getText().toString())) | |
.doOnNext(ignored -> { | |
submitView.setEnabled(false); | |
progressView.setVisibility(VISIBLE); | |
}) | |
.flatMap(event -> service.setName(event.name)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.doOnNext(ignored -> progressView.setVisibility(GONE)) | |
.subscribe(s -> finish(), t -> { | |
submitView.setEnabled(true); | |
Toast.makeText(this, "Failed to set name: " + t.getMessage(), LENGTH_SHORT).show(); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment