Skip to content

Instantly share code, notes, and snippets.

@Diolor
Last active June 11, 2016 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Diolor/76c65fcc128687845114a561a2cb9ad0 to your computer and use it in GitHub Desktop.
Save Diolor/76c65fcc128687845114a561a2cb9ad0 to your computer and use it in GitHub Desktop.
PublishSubject<Void> viewClickedSubject = PublishSubject.create();
CompositeSubscription startStopCompositeSubscription = new CompositeSubscription();
protected void onStart() {
view.setOnClickListener(v-> viewClickedSubject.onNext(null));
Subscription subscription = viewClickedSubject
.flatMap(aVoid-> api.getAlert())
.subscribe(this::makeAlertToast, Throwable::printStackTrace);
startStopCompositeSubscription.add(subscription);
}
protected void onStop() {
startStopCompositeSubscription.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment