In RxRoom
, Flowable
will always emit atleast one item, so using single()
and isEmpty()
functions won't work as expected.
So, the one where you are checking if projects are cached or not using isEmpty()
function, room will still emit one item which would be an empty list object. This happens because even if no values exist in db, Room will still create an empty list first and then try to populate it if any items exist. Finally, it would emit the list object even if it is empty.
You can resolve this issue by updating the areProjectsCached()
function in ProjectsCacheImpl.kt
like this:
override fun areProjectsCached(): Single<Boolean> =
projectsDatabase.cachedProjectsDao()
.getProjects()