Skip to content

Snapchat/recycling-center

Repository files navigation

Recycling Center

Recycling Center is a library designed to support a pattern: reactive, unidirectional data flow using immutable ViewModels. It combines the reactive data flow of RxJava with the efficient UI of a RecyclerView, and supports UI composition via Sections of Views and ViewModels.

pipeline

Getting Started

Recycling Center uses several primitives to create an efficient RecyclerView. See the Adding a Custom View guide for how they fit together, and a code sample to see it in action.

  • AdapterViewType: Each view in the RecyclerView has an enumerated type.
  • AdapterViewModel: Contains all the data needed to render a view, ideally including any formatting.
  • ViewBinding: Binding code that connects a ViewModel to its View.

A ViewFactory creates a View from an AdapterViewType. The ViewFactory supports background-inflated views from a ViewPrefetcher.

The Recycling Center RecyclerView.Adapter adhere to the ViewModelAdapter interface. There are a few different adapters for different use-cases:

Instead of Lists of ViewModels, the Recycling Center uses a Seekable interface to bring content to an Adapter. This simplified interface supports simple list-based binding via Seekables.copyOf(list) or efficient, fluid binding from a Cursor or other seekable stream of data.

Resources