Cash App Benoît Quenaudon Jun 9, 2020

A Great Way to do Android Presenters

Article Summary

Cash App's Android team chose presenters over ViewModels and MVVM. Here's why their "boring" code wins.

Benoît Quenaudon from Cash App shares their presenter pattern that uses RxJava to create a uniform, testable architecture. Every presenter follows the same contract: view events in, view models out.

Key Takeaways

Critical Insight

A consistent presenter pattern with unidirectional data flow creates code that's easy to write, review, and test across the entire team.

The article reveals how they visualize presenters as waterfalls and why database queries must run at subscription time, not instantiation.

About This Article

Problem

Cash App's Android team needed a presenter pattern that enforces unidirectional data flow. Data had to move strictly downward from view events to view models, avoiding the complexity that comes when data flows back up through asynchronous streams.

Solution

Benoit Quenaudon's team built presenters that extended ObservableTransformer with a waterfall visualization approach. Database queries and asynchronous sources only execute when the stream gets subscribed to, not when the presenter is created. They used RxJava's merge and publish operators to make this work.

Impact

The presenter contract delegated side effects to a Launcher interface, which made testing straightforward. The team could verify behavior like URL launches using PublishSubject and TestObserver without needing complex mocking frameworks.