RxJava's Consequences: Laziness
Let's address the issue of the violation of RxJava's laziness principle.
We'll cover the following
Issue: Violation of RxJava’s Laziness
RxJava is designed with laziness in mind. Revisit Lazy Emissions]for a reminder. That is, no long operations should be performed when there are no subscribers to the Observable
. With this modification, that assumption is no longer true since UserCache.getAllUsers()
is invoked even before there are any subscribers. Whether or not the backing cache is in memory or on disk, this operation should be postponed until an Observer
subscribes to it, to stay true to RxJava principles.
Get hands-on with 1200+ tech skills courses.