Revolut Roman Iatcyna Nov 29, 2019

Reactive Data Flow in Revolut Android App

Article Summary

Roman Iatcyna from Revolut reveals how they built a reactive data layer that handles offline-first architecture at scale. Their solution? A custom DataObservableDelegate that abstracts away the complexity of multi-source data management.

Revolut's Android app supports full offline mode across every screen, requiring sophisticated data synchronization between memory cache, database, and network. The team built a reactive architecture using RxJava that automatically manages cache-first strategies while keeping the domain layer simple. They've now open-sourced this as RxData library.

Key Takeaways

Critical Insight

Revolut abstracted their entire offline data flow into a single delegate pattern that handles memory cache, database persistence, and network requests automatically while exposing a simple Observable interface to developers.

The article includes detailed diagrams showing exactly how data flows through the system in different scenarios, plus the actual code for implementing nested entities like their Portfolio and Holdings.

About This Article

Problem

Revolut's Android team had different offline data strategies scattered across repositories. Some teams used Subjects, others used concat or merge operators, and there was no consistency. This created maintenance problems and a lot of duplicated logic.

Solution

Roman Iatcyna's team built DataObservableDelegate (DOD), a delegate pattern that standardizes the Data Flow Protocol. It accepts lambdas for fetching data from memory or the database and handles storage. Teams can also use partial declarations if they need flexible cache configurations.

Impact

When new repositories are added, teams only need to test the additional DOD lambda logic instead of rewriting entire offline flows. This cuts down on boilerplate code. The team was able to open-source the work as RxData, a standalone library available via compile 'com.revolut.rxdata:dod:1.0'.