Sorting and Filtering Records Using Room DataBase and Kotlin Flow
Build reactive Android apps with ease
Four things to make the code efficient and maintainable.
Sorting & Filtering should be done by room database, our view-models or repos shouldn’t have any logic related to them.
Things can be in any combination — the user might want to filter and sort or only sort or only filter. Implementation should support all possible cases.
Implementation should be concise and simple.
UI should be synced with the database all the time. For suppose if any new record is added or removed it should reflect on UI without any additional work respecting the existing conditions.