Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM on Android with DataBinding or RxJava?

I am building an Android app and am fairly new to both MVVM and data binding concepts on Android.

I have read at a few places ( like here) that both RxJava and Google's DataBinding library can be used for implementing MVVM pattern.

I went through the official Android documentation for DataBinding and am going through a project referenced by Google on Mvvm using DataBinding. However, I have no idea how RxJava works as of yet, which might be obvious from the question.

My question is, keeping in mind the long term goals of extending my app, is it worth investing effort in learning RxJava? Or does DataBinding suffice as a complete substitute for it? I don't know RxJava at all but by reading about it online gives me the impression that it can solve a wide range of problems.

I do not mind investing time in learning RxJava but is it worth the effort than simply using Google's DataBinding (which I have some sort of grasp on)?

like image 803
Rajan Prasad Avatar asked May 04 '17 05:05

Rajan Prasad


People also ask

What is the use of Data Binding in Android?

The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.

What is MVVM Architecture in Android?

MVVM stands for Model, View, ViewModel. Model: This holds the data of the application. It cannot directly talk to the View. Generally, it's recommended to expose the data to the ViewModel through Observables. View: It represents the UI of the application devoid of any Application Logic.

What is LiveData in MVVM Android?

LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.

What is two way Data Binding Android?

Two-way Data Binding is a technique of binding your objects to your XML layouts so that the layout can send data to your binding object. This is compared to a “traditional” or “one-way” Data Binding setup, where data would only move from your binding object to the layout.


1 Answers

RxJava is a completely different concept than DataBinding. It's more of a way of handling concurrency than it is about binding data. I 100% think it's worth learning. The Android community has embraced it with open arms.

Shameless plug: I compiled a list of RxJava resources awhile back - http://gregloesch.com/dev/2014/10/20/resources-for-learning-rxjava-android.html

like image 100
loeschg Avatar answered Sep 19 '22 02:09

loeschg