I’m a huge fan of unidirectional data flow, reacti...
# rx
z
I’m a huge fan of unidirectional data flow, reactive databases and immutable data. Examples include StorIo, SqlBrite/SqlDelight. But how do you avoid huge object allocation for small changes in a list? note:
EmailEntity
is POJO for how an email is stored in the database.
EmailViewModel
is POJO for how email is displayed in UI 1. I have a list of 1000 emails in a database table,
EmailTable
2. must display them in a
RecyclerView
. 3.
EmailDb
repository class emits a
List<EmailEntity>>
(size == 1000) 4.
List<EmailEntity>
of 1000 emails is mapped into a
List<EmailViewModel>
5.
List<EmailViewModel>
is displayed in the View. 6. User reads email, marking it as read. 7.
EmailTable
record is updated to indicate email was read 8.
EmailDb
emits a new
List<EmailEntity>>
of the 1000 emails 9.
List<EmailEnitity>
is mapped to a new
List<EmailViewModel>
Steps #8 and #9 allocate 2000 new objects for 1 mutation (email being marked as read). How do you avoid this while still using unidirectional data flow and rx?
👍 1