Skip to content
Branch: master
Find file History
mmcwong Use SavedStateRegistry for persisting state (#254)
* Import saved state library

* Use SavedStateRegistry for persisting state

* PR feedback and update tests

* PR feedback

* Remove BaseMvRxActivity

* Throw exception before calling createViewModel

* Update to alpha-03

* Fix versioning

* Remove merge conflict

* Fix activity lifecycle bug

* Fix existingViewModel

* PR feedback

* Update error message and testing
Latest commit 3e0924c Oct 16, 2019

README.md

ToDo MvRx

gif

This ToDo app follows the specification outlined in the Google Samples Android Architecture repo.

It is 100% feature complete and has significantly fewer lines of code compared to other archtiecture blueprints. Running cloc on src/main for MvRx yields:

Language LOC MvRx mvp-kotlin mvvm-live-kotlin mvp mvp-clean mvp-java
Kotlin 803 1541 1564 0 0 0
Java 0 0 0 2171 2777 2145
XML 501 608 751 608 608 611
Total 1304 2149 2315 2779 2385 2756

Architecture

ToDo-MvRx uses Room, Epoxy, and Navigation Components for its core architecture.

It then uses TasksViewModel to act as an in-memory cache and owner of multiple repositories. It could merge db + network but for the sake of having an actual single source of truth, it loads two different database sources that connect to the same database but have different artifical delays. It then proxies all tasks calls to each of them.

All task state is shared between Fragments using this ViewModel.

Snackbars for actions like adding a task are handled using this block of code which compares state changes to see when tasks have changed.

You can’t perform that action at this time.