thomasnield / packt_learning_rxjava

Code examples for the Packt book "Learning RxJava"
https://www.packtpub.com/application-development/learning-rxjava
2 stars 3 forks source link

Ch3_48 onError never gets fire #1

Open chhil opened 6 years ago

chhil commented 6 years ago

Using rxJava2.1.3

Is it expected behavior that the RECEIVED ERROR never gets printed. I replaced all the elements in the array with 0's and made sure I did not miss the error being printed.

    Observable.just(5, 2, 4, 0, 3, 2, 8)
    .map(i -> 10 / i)
    .retry()
            .subscribe(i -> System.out.println("RECEIVED: " + i),
                    e -> System.out.println("RECEIVED ERROR: " + e));

p.s. Love the book, explains everything very clearly.

thomasnield commented 6 years ago

Hi @chhil, that is the intent because the retry() will keep swallowing the error and re-subscribing infinitely, always intercepting the error so it never goes downstream to the subscribe().

Thanks for getting my book and I'm glad it's helping you : )

chhil commented 6 years ago

Hi @thomasnield, Thank you the quick response.

This means that the retry(n) retries n times on the failure and if it fails after that it gets into the error handler and exits.

thomasnield commented 6 years ago

Exactly.