Skip to content

ThuanPx/Android_Architecture

 
 

Repository files navigation

Android Architecture: MVVM

Introduction

  • MVVM is one of the architectural patterns which enhances separation of concerns, it allows separating the user interface logic from the business (or the back-end) logic.Its target (with other MVC patterns goal) is to achieve the following principle “Keeping UI code simple and free of app logic in order to make it easier to manage”.

  • Model

Model represents the data and business logic of the app. One of the recommended implementation strategies of this layer, is to expose its data through observables to be decoupled completely from ViewModel or any other observer/consumer (This will be illustrated in our MVVM sample app below).

  • View

The view role in this pattern is to observe (or subscribe to) a ViewModel observable to get data in order to update UI elements accordingly.

  • View Model

ViewModel interacts with model and also prepares observable(s) that can be observed by a View. ViewModel can optionally provide hooks for the view to pass events to the model. One of the important implementation strategies of this layer is to decouple it from the View, i.e, ViewModel should not be aware about the view who is interacting with.

Libraries Used

  • Koin A pragmatic lightweight dependency injection framework for Kotlin developers.

  • Kotlin Coroutines For managing background threads with simplified code and reducing needs for callbacks

  • ViewModelScope Which helps you to manage when your coroutines should run.

  • ViewModel - Store UI-related data that isn't destroyed on app rotations. Easily schedule asynchronous tasks for optimal execution.

  • LiveData - Build data objects that notify views when the underlying database changes.

About

No description or website provided.

Topics

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages