A Lesson by Craig Russell
This lesson describes the similarities and differences between the RxJava defer and fromCallable operators.
The operators are very similar and both can be used to solve the same type of problem: converting an expensive method call into an RxJava Observable.
This lesson describes the benefits of each and offers a recommendation on which you should use.
In this lesson you will learn:
- What version of RxJava is required for each operator
- Advantages of using fromCallable over defer
- How fromCallable can result in writing less code
- Why fromCallable provides better error handling
- An example problem showing solutions using both fromCallable and defer
- How compact the code can become when using Retrolambda
Code for the Lesson
Pro members: Log in to view the code for this lesson!
Lessons in this course
- RxJava: fromCallable vs defer – The differences between the two operators
- RxJava Operators – defer()
- RxJava Marble Diagrams
- RxJava fromCallable – Converting slow methods into an Observable
- RxJava Operators – observeOn
- RxJava Operators – subscribeOn
- Retrofit 2 with RxJava
- Grokking RxJava’s Observable.amb Operator
- Understanding the RxJava Observable.zip Operator
- RxJava Error Handling with Observable.error()
- Introduction to RxJava for Android Developers