This project follows the course Model-View-Intent (MVI) Architecture and will implement an Android project using MVI. We'll build an event driven architecture leveraging the MVVM architecture.
This architecture pays off when you share the same ViewModel between multiple fragments for instance. It'd be a nightmare keeping multiple LiveData for each view.
- Kotlin
- Coroutines
- Retrofit2
- Glide
- ViewModels
- Repository pattern
- NetworkBoundResource (as recommend by architecture guide in google sample. See here ).
The two possible actions here:
- Get 'User' data from open-api.xyz/placeholder/user.
- Get a list of 'BlogPost' data from open-api.xyz/placeholder/blogs.
Those two will be handled by MainStateEvent that has three possible events:
- GetBlogPostsEvent
- GetUserEvent
- None
For a bigger project we'd have a StateEvent for each ViewModel and a ViewState for each
When you fire off and event like get user event, this event will be handled by the method setStateEvent inside MainViewMode. The switchMap from dataState will trigger fetching the data in the repository. The response of this event will be returned as a LiveData thru the viewState in the ViewModel. The fragment observing it will handle the answer and show it properly.