RxJava2-Android-Samples icon indicating copy to clipboard operation
RxJava2-Android-Samples copied to clipboard

Thread Interrupted

Open khaledkhj opened this issue 8 years ago • 5 comments

Any idea how to handle "thread interrupted"?

This happens due to calling the instant search api!

Thank you.

khaledkhj avatar Oct 26 '17 07:10 khaledkhj

We can handle that by using onErrorResumeNext.

amitshekhariitbhu avatar Oct 26 '17 07:10 amitshekhariitbhu

Thank you for the prompt reply, but can you please show an example on how to use it?

khaledkhj avatar Oct 26 '17 08:10 khaledkhj

I tried onErrorResumeNext without any luck. After InterruptedIOException it just won't emit. Looks like some ongoing request's Observable is getting unsubscribed at wrong time. Anyone got any idea?

Apsaliya avatar Jan 30 '18 05:01 Apsaliya

Ok, So for those who are still facing this, I managed to solve this by providing a scheduler to my switchMap . So unsubscribe on your previous calls won't affect on your current one.

Apsaliya avatar Jan 30 '18 13:01 Apsaliya

i had same issue "my subscription terminated once an error is emitted",but this one help me

.switchMap(new Func1<String, Observable<Response>>() {
    @Override public Observable<Response> call(String query) {
        return retrofitService.search(query)
                .onErrorResumeNext(Observable.<Response>empty());
    }
})

@khaledkhj @Apsaliya

SherifMuSherif avatar Feb 06 '18 15:02 SherifMuSherif