Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emit each item from Flowable Room ORM

I have a list of items in the Room ORM which I would like to display in a Recycler view. The data is being added from the network to the db. The problem is I am getting every time the whole list emited from the Flowable and not each item. I have tried with .distinctUntilChanged with no difference.

@Query("SELECT * FROM items")
Flowable<List<Item>> getItems();

I have tried also to return only a single item which loads only the first one that is the db.

like image 998
Rene Gens Avatar asked Nov 30 '22 15:11

Rene Gens


1 Answers

Yes, Flowable<List<Item>> means you'll get a single callback when the list changes: this is how Room works. Generally, you'd pass that list into DiffUtil, which then generates the set of changes needed to update your RecyclerView.

like image 136
ianhanniballake Avatar answered Dec 04 '22 13:12

ianhanniballake