A simple example of async tasks which happen in every application.
Objectives: Request list of repositories for a user from Github API. Asynchronously request the last commit for each repo. Add a Data Persistency Layer. Add unit tests.
-
View-ViewModel-Repository
as an architecture pattern (without data binding). View includes Android classes, the rest can be tested with JUnit. -
RepoWithCommitListViewModel
loads list of repos first, then asks each repo for the last commit and notifies View when it's done. -
Network (Retrofit) and DB (Room) requests in Repository run with Kotlin coroutines
-
Unit tests for Repository.
-
Config change handling. There are different ways to tackle this problem, e.g. store ViewModels in retained fragment, then reattach to new View or implement full Rx solution etc.
-
Some things are implemented "well enough", but require tuning before going live in production. E.g.
notifyDataSetChanged()
is called on adapters every time a single row changes. -
Proper DI