The puropse of this repo is to experiment with MVI and Coroutines in a clean architecture. As a consequence it is a bit verbose.
The app runs on a very basic implementation of the MVI pattern based on Spotify's Mobius (there are some very similar frameworks, like Badoo's, Spotify's, RxRedux, etc.).
The implementation can be found in the usecase module.
The view is effectively decoupled from Mobius or any framework:
all the view cares about are Models
(that receives and renders on screen)
and Events
(that emits when the user interacts).
Model, Event, Effect are super simple immutable data classes.
The view is completely stateless.
As a consequence Espresso tests are very simple and effective.
Compared to Badoo's MVICore it seems that is a bit less
easy to implement features like navigation and transient messages.
This is because the view listens to events of only one type, while MVICore has a second event type, News
,
that is used to model one-off occurrences.
Models, Events, Effects are processed by pure functions.
The state is stored in the Controller
, retained in a ViewModel
, the Controller re-emits the latest Model
when connects.
Long running operations happen in the UseCase
(specifically in the
RepositoryUseCase
).
The Activity
connects and disconnects in onResume
and onPause
,
and so does not leak the connection.
A simple clean architecture (see dependency graph) of Gradle modules connected via Dagger.
Coroutines and Kotlin instead of RxJava (see RepositoryUseCase
).
Mobius, Dagger and:
- Simple Xml
- AndroidX
- LeakCanary
- Retrofit
- Architecture Components:
- Room
- ViewModel
- For testing
- Mockk
- JUnit 5
- AssertJ
- Espresso
- android-ui (Espresso tests)
- repository (JUnit 5 tests)
- network (no unit tests, only configuration of Retrofit)
- usecases (JUnit 5 tests)
- entities (no tests, only interfaces here...)