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
- Lesson 179: RxJava: fromCallable vs defer – The differences between the two operators
- Lesson 151: RxJava Operators – defer()
- Lesson 148: RxJava Marble Diagrams
- Lesson 147: RxJava fromCallable – Converting slow methods into an Observable
- Lesson 142: RxJava Operators – observeOn
- Lesson 139: RxJava Operators – subscribeOn
- Lesson 68: Retrofit 2 with RxJava
- Lesson 21: Grokking RxJava’s Observable.amb Operator
- Lesson 20: Understanding the RxJava Observable.zip Operator
- Lesson 19: RxJava Error Handling with Observable.error()
- Lesson 17: Introduction to RxJava for Android Developers