Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Created April 14, 2017 15:41
Show Gist options
  • Save benigumocom/3e942f4e39abc34153c2f6cef9f5f76c to your computer and use it in GitHub Desktop.
Save benigumocom/3e942f4e39abc34153c2f6cef9f5f76c to your computer and use it in GitHub Desktop.
Managing State 1
disposables.add(RxView.clicks(submitView)
.doOnNext(ignored -> {
submitView.setEnabled(false);
progressView.setVisibility(VISIBLE);
})
.flatMap(ignored -> service.setName(nameView.getText().toString()))
.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