RxJava icon indicating copy to clipboard operation
RxJava copied to clipboard

No option for ConcatMap with skip error

Open kagile opened this issue 8 years ago • 8 comments

Version : RxJava1

Consider this example: I have a file downloading in sequence. If one download fails, it should move to next. Psudo code:

Observable.from(urls)
 .concatMap(url -> downloadObservable(url)) 

There is no option for moving to next url if the download fails. There is no way to skip with onErrorResumeNext() as I just want to move to next url.

kagile avatar Jan 05 '18 09:01 kagile

Please make sure you have the latest 1.x version and check the available operators again.

akarnokd avatar Jan 05 '18 10:01 akarnokd

@akarnokd I have latest version 1.x. No offense, but the docs are like explaining rocket science. Can you just hint the operator?

kagile avatar Jan 05 '18 10:01 kagile

What's in the suggestion list when you start typing .concatMap in your IDE?

akarnokd avatar Jan 05 '18 10:01 akarnokd

concatMapEager and concatMapDelayError are there. I think concatMapDelayError would work. But that isn't mentioned clearly in docs that it will switch next. Also, I need the count of failed items, can I use doOnError for that after concatMapDelayError ?

kagile avatar Jan 05 '18 10:01 kagile

But that isn't mentioned clearly in docs that it will switch next.

That would be logically contradictory, no? Why have a delayError operator when it just stops after the first error. Also the JavaDoc is pretty clear IMO:

"Maps each of the items into an Observable, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the inner Observables till all of them terminate."

Also, I need the count of failed items, can I use doOnError for that after concatMapDelayError?

No. There is only at most one call to onError after concatMapDelayError which in this case could be a single arbitrary Throwable or a CompositeException for more than one failing source.

akarnokd avatar Jan 05 '18 11:01 akarnokd

But I don't want to stop after first error. I want to move to next url in concatMap.

kagile avatar Jan 05 '18 11:01 kagile

I'm facing the same problem. I have handled the error correctly, but I need to continue with the next observable.

mattid89 avatar Jan 09 '19 17:01 mattid89

@mattid89 how did you solve this?

Sisekelo avatar May 10 '21 11:05 Sisekelo