What is a result of this Dao
method after inserting some message
s in the database:
@Query("SELECT * FROM messages")
Flowable<List<Message>> getMessages();
1 - ALL message
s stored in the database will be emitted after this change
or
2 - Only the DIFFERENCE beetwen new and old message
s will be emitted after the change?
In which documents is it specified? If first, what should I do to get the difference - something like DiffUtils
or there are other approaches?
P.S. What if I DELETE some messages?
LiveData<List<Message>>
instead. The behavior is the same and you don't need to worry about disposing your subscriptions, nor worry about configuration changes. However, I would use Single
or Maybe
when you have to return a single result.Update: instead of getting all the messages and seeing the difference between them using DiffUtils, you can retrieve a subset of the messages and update it on demand. The new Paging library in Android helps you doing this. Again, there is a lot of information around about how to do this so I am not going to put the details of the implementation here because it is out of the scope of the question, but here you have one of the many tutorials available.