News

Airbnb introduces MvRx, a new Android framework for easier, faster, and high-quality product development

2 min read

Yesterday, Airbnb open sourced MvRx (pronounced mavericks), their Android architecture. MvRx received an astounding adoption rate when it was first introduced to the engineers at Airbnb in July. Later, it became their standard way of writing screens and now it is used for nearly all of their product development. Due to its popularity among Airbnb’s app developers, they have decided to share it with all Android developers.

MvRx is based on Kotlin, which helped MvRx’s developers to leverage several powerful features provided by the language to build a cleaner API. It is built on top of the following technologies and concepts:

  • Kotlin
  • Android Architecture Components
  • RxJava
  • React (conceptually)
  • Epoxy (optional but recommended)

Why you should use MvRx?

Using MvRx you will be able to write simple and complex Android screens easily. MvRx also helps making certain tasks easier and faster for Android app developers such as:

  1. Saving view state and business logic in onSaveInstanceState properly
  2. Creating layouts with a toolbar, RecyclerView, and footer over and over again
  3. Executing the onSuccess and onFailure handlers for asynchronous requests
  4. Dealing with the Android lifecycle

What are its core concepts?

  • State: MvRxState is an interface that you need to extend with an immutable Kotlin data class. It contains the properties necessary to render your screen.
  • ViewModel: All the business logic and anything other than just rendering views is handled by MvRxViewModels. It extends Google’s ViewModel. The following lifecycle diagram clearly illustrates how ViewModels simplify lifecycles on Android:

Source: GitHub

  • View: MvRxView is a simple interface that users see and interact with. It is a LifecycleOwner consisting of a invalidate() function that gets called any time there is a change in the state of its ViewModels.
  • Async: MvRx makes handling async requests like fetching from a network or a database easier using Async. It is a Kotlin sealed class with four types: Uninitialized, Loading, Success, and Fail. MvRx provides an extension to map Observable<T> to an Async<T> property on your state to make executing network requests and other actions easy with a single line of code.

How can you install it?

To use MvRx, you need to add the following dependency to your project in the build.gradle file:

dependencies {

 implementation 'com.airbnb.android:mvrx:0.5.0'

}

To know about the other details of MvRx, you can refer to its GitHub repository and also read Airbnb’s official announcement.

Read Next

RxAndroid 2.1.0 is out with newly added Async API!

Dagger 2.17, dependency injection framework for Java and Android, is now out!

Did you know your idle Android device sends data to Google 10 times more often than an iOS device does to Apple?

Bhagyashree R

Share
Published by
Bhagyashree R
Tags: Android News

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago