Learn Android MVVM architecture components with kotlin

houman.sanati picture houman.sanati · Feb 6, 2019 · Viewed 7.5k times · Source

After searching about android architecture components I realized that MVVM is better than other architectures at some points so I started to learn MVVM and I'm using Kotlin language but the problem is when I search for tutorials to start learning I found many components like RxJava, RxAndroid, Dagger2, Room, Lifecycle and etc. but they don't say why they are using them and why they choose some specific components. i will show you some examples :

1- Android MVVM with Dagger2, Retrofit, RxJava

2- Android MVVM with Dagger2, Retrofit, RxAndroid

3- Android app with MVVM dagger2 RxJava Livedata and Room

My questions are :

1- How should I decide to choose some of these components and work with them?

2- How should I know that I need to use some of them together(for example Livedata and RxJava)?

This is really confusing for me and I don't know how to start.

Answer

Sushant Poman picture Sushant Poman · Feb 7, 2019

First you need to individually understand why to use Kotlin, MVVM, Dagger, RxJava, Retrofit.

MVVM and Kotlin:

https://medium.com/@zhangqichuan/android-development-with-mvvm-and-kotlin-9598c3623ce1

RxJava and RxAndroid:

RxAndroid is an extension to RxJava(Used for handling threads and asynchronous tasks), for more details check following links: Difference between RxJava and RxAndroid? https://www.quora.com/What-is-the-difference-between-Retrofit-and-RxJava-RxAndroid

Retrofit:

https://medium.com/@elye.project/kotlin-and-retrofit-2-tutorial-with-working-codes-333a4422a890

LiveData and room with kotlin:

Room is a database layer on top of an SQLite database which used to remove boilter plate while fetching data from local sqlite database, use following links: https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin/#0

After understanding this components(Kotlin, MVVM, Dagger, RxJava and RxAndroid, Retrofit, LiveData) individually then you need to do all this things in single project, use following link:

https://github.com/egek92/Kotlin-MVVM-LiveData-Room