How CellViewModel and CollectionViewModel work together
mainReactiveCollectionsKit uses a uni-directional data flow pattern based on two core components:
CellViewModel: The "atomic" component. It encapsulates all data, configuration, interaction, and registration for a single cell. It is responsible for defining how a cell is configured and how it handles interaction events.CollectionViewModel: The immutable representation of the entire collection structure. It acts as the "driver" for the collection.
The Workflow:
- Fetch or update your underlying data models.
- Generate
CellViewModelobjects and a completeCollectionViewModelfrom that data. - Set the
CollectionViewModelon theCollectionViewDriver. - The driver performs a diff against the previously set model and updates the
UICollectionViewautomatically.
# Example workflow concept
# 1. Data -> 2. CellViewModels + CollectionViewModel -> 3. Driver -> 4. UI