To be honest, Airbnb in the open source community, is really can not be ignored, a huge contribution to the existence. So far, it has opened 165 projects on GitHub, including the well-known Lottie repository, a cross-platform animation solution for mobile.

Airbnb recently added a new member to its GitHub page: MvRx.

Before introducing MvRx, consider the context in which the project was born. Note: For ease of expression, Airbnb is referred to in the first person.

The introduction of

  • With tourism booming, Airbnb is growing faster than ever, and more people are using Airbnb products to start traveling. This year alone, we’ve launched Airbnb Plus, along with countless other projects we can’t wait to share.
  • On the Android side, the almost astronomical commercial growth has kept us developers very busy. We have more things to do on the app side than ever before. Over the past year, we’ve added 286 pages, and we show no signs of slowing down. To make our lives easier, we started looking for patterns that prevented repetitive work and helped us focus on the iterative product itself.

Introduction to the

Today, we’re ready to share our Android architecture: MvRx (pronounced “Mavericks”). MvRx was born out of the knowledge that we were solving the same problems, Beijingxia, over and over again, so that we stopped focusing on developing products. On the Android side, there are countless small jobs that engineers have to do or consider to keep the app high quality. Such as:

  • Create layout files with toolbars, RecyclerView, and Footer over and over again;
  • Intertwined with the Android life cycle;
  • Save view state and business logic correctly;
  • OnSuccess and onFailure callback handling for asynchronous requests such as network and database calls;

MvRx makes all of this much easier. We set out to do this with one goal: to make it easier, faster and more fun to build a quality product. It wasn’t our intention to open source the framework, but as MvRx took shape, we knew we had to do it. Not only do we want to share with the outside world, but we also want MvRx to be used outside of Airbnb for our own projects, because it can scale from a hobby project to an app with 70 engineers and nearly a million lines of code.

practice

MvRx is based on Architecture Components, RxJava, Epoxy, and Kotlin. Designing around the Kotlin language allowed us to build a cleaner API than the Java language implementation.

Something like this:



In this simple Fragment, with only 18 lines of code, we have a ViewModel whose scope is limited to the Fragment but will be retained in configuration changes, along with the default layout and testable state of the page. When the state changes, the page will be updated automatically, and only the specific parts of the actual change will be updated to RecyclerView. Also, all of this code you see runs in background threads, because MvRx handles threads seamlessly.

MvRx at Airbnb

  • In just a few months, MvRx has gone from a pilot phase to the standard way we write nearly all new pages, and developers love it. In the latest survey, 93% of engineers surveyed (n = 14) gave a rating of 8/10 or higher.
  • In addition, the adoption rate of MvRx is staggering. Growth in the pilot phase was very steady, but when we opened it up to all teams in July, usage continued to climb.
  • In just a few months, we’ve built over 110 pages using MvRx, and it’s quickly being adopted as the preferred approach for anything from simple static features to some of the most complex features in our app

Begin to use

We are happy to share MvRx with the world. If you want to learn more, please visit MvRx’s GitHub Wiki page to learn and use!

This is the introduction of MvRx’s new architecture solution from Airbnb engineers. Do you have the urge to try?


This article is not easy, if you like this article, or helpful to you hope you more, like, forward, follow oh. The article will be updated continuously. Absolutely dry!!