Airbnb Eli Hart Apr 4, 2024

Introducing Trio | Part II

Article Summary

Airbnb's Android team just solved one of mobile architecture's hardest problems: navigation in massive, modularized apps. Their solution? Store navigation state right in the ViewModel.

In Part II of their Trio framework series, Airbnb engineers Eli Hart, Ben Schwab, and Yvonne Wong reveal how they built a Compose-based navigation system that works across 2000+ modules. This isn't your typical navigation library.

Key Takeaways

Critical Insight

Airbnb's Trio framework treats navigation as state, making complex screen flows testable, type-safe, and perfectly suited for large modularized codebases.

Part III reveals how Props enable dynamic communication between screens, completing Trio's architecture puzzle.

About This Article

Problem

Airbnb's codebase has over 2000 modules, and feature modules that need to communicate without direct instantiation create circular dependency risks. This threatens build speeds and makes ownership boundaries unclear.

Solution

Trio's Router system uses Dagger multibinding with KSP compile-time validation. Feature modules connect through navigation modules with a 'nav' suffix, which decouples them and eliminates circular dependencies while keeping type safety intact.

Impact

The Router's createTrio function matches Arguments and Props types at compile time, preventing navigation errors at runtime. This lets large modularized applications handle cross-module screen transitions reliably.