How to subscribe to click events so exceptions don't unsubscribe?

I'm using RxJava for Android (RxAndroid) and I subscribe to click events of a view, and do something on them as follows:

subscription = ViewObservable.clicks(view, false) .map(...) .subscribe(subscriberA);

The problem is whenever there is an exception, subscriberA automatically unsubscribes, leading to the next click not triggering anything.

How to handle exceptions so to intercept all the click events regardless of exceptions being thrown?


Use retry method:

subscription = ViewObservable.clicks(view, false) .map(...) .retry() .subscribe(subscriberA)

However, you will not receive any exception in onError. To handle exceptions with retry (resubscribe) logic use retryWhen:

subscription = ViewObservable.clicks(view, false) .map(...) .retryWhen(new Func1<Observable<? extends Notification<?>>, Observable<?>>() { @Override public Observable<?> call(Notification errorNotification) { Throwable throwable = errorNotification.getThrowable(); if (errorNotification.isOnError() && handleError(throwable)) { // return the same observable to resubscribe return Observable.just(errorNotification); } // return unhandled error to handle it in onError and unsubscribe return Observable.error(throwable); } private boolean handleError(Throwable throwable) { // handle your errors // return true if error handled to retry, false otherwise return true; } } .subscribe(subscriberA)


  • OCaml non-blocking client socket
  • How can I handle several store instance in the same action using Sencha Touch 2?
  • jQuery.on “touchstart mousedown” - both events are triggered on touchscreen device
  • Get the elements of HTML tags inside data-content of popover
  • How do you download a image/png data URI in Edge?
  • How to make a variable by extracting specific line?
  • R Remove zeros at the start and end of a column
  • ng-pattern that allows decimal ratios
  • Custom URI routing by query string with CodeIgniter?
  • prevent datepicker from triggering parent mouseleave
  • ansible playbook unable to continue as the `tar` fails due to `file change as we read`
  • How can I stop my python script when another python script is running?
  • How to set the navigation bar to the top in Table View?
  • JPA/Hibernate - Entity name seems to be important. If I rename to “Bob” works fine
  • Show records ordered with maximum price first in PHP & MySQL
  • Ability to use Bootstrap 3 grid system to specify width of select element
  • goJS dropdown remove items
  • Jquery UI Sortable, move item automatically
  • How does the HEXTORAW() function work? What is the algorithm?
  • to implement a spinner in angular2+
  • What is the undocumented SessionIdInterface in PHP 5.5?
  • File extension of zlib zipped html page?
  • Failed to find version-tag string. File must be updated
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • Servlet stops working on Tomcat server after some hits or time
  • x64 applications using gdi+: what are the consequences on performance?
  • Django rest serializer Breaks when data exists
  • How to rebase a series of branches?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Azure Cloud Service Web Role web pages do not load
  • swift auto completion not working in Xcode6-Beta
  • Excel - Autoshape get it's name from cell (value)
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • javascript inside java/jsp code
  • what is the difference between the asp.net mvc application and asp.net web application
  • Hazelcast - OperationTimeoutException
  • Android Studio and gradle
  • Cant find why the layout is getting smaller
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can i traverse a binary tree from right to left in java?