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
- Two-level cache system: memory cache beats DB, DB only queried once per session
- DataObservableDelegate wraps complex offline logic into single reusable component
- Cache-first strategy renders UI instantly, then updates from network seamlessly
- Repository contract returns Observable<Data<T>> with loading, content, and error states
- Open-sourced as RxData library with comprehensive test coverage
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.
About This Article
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.
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.
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'.