Skip to content

A simple example of async tasks which happen in every Android application (coroutines, unit tests, ViewModel)

License

Notifications You must be signed in to change notification settings

oleksandr-yefremov/asyncnetworking

Repository files navigation

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.

What is implemented:

  1. View-ViewModel-Repository as an architecture pattern (without data binding). View includes Android classes, the rest can be tested with JUnit.

  2. RepoWithCommitListViewModel loads list of repos first, then asks each repo for the last commit and notifies View when it's done.

  3. Network (Retrofit) and DB (Room) requests in Repository run with Kotlin coroutines

  4. Unit tests for Repository.

What is not implemented:

  1. 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.

  2. 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.

  3. Proper DI

About

A simple example of async tasks which happen in every Android application (coroutines, unit tests, ViewModel)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages