CollectionSectionViewModel

public struct CollectionSectionViewModel

View model for a collection view section.

  • The key used by the diffing algorithm to uniquely identify this section. If you are using automatic diffing on the CollectionViewDriver (which is enabled by default) you are required to provide a key that uniquely identifies this section.

    Typically you want to base this diffing key on data that is stored in the model. For example:

     public var diffingKey = { group.identifier }
    

    Declaration

    Swift

    public var diffingKey: String?
  • Initializes a collection view section view model.

    Declaration

    Swift

    public init(
        cellViewModels: [CollectionCellViewModel],
        headerViewModel: CollectionSupplementaryViewModel? = nil,
        footerViewModel: CollectionSupplementaryViewModel? = nil,
        diffingKey: String? = nil
        )

    Parameters

    cellViewModels

    the cells in this section.

    headerViewModel

    the header view model (defaults to nil).

    footerViewModel

    the footer view model (defaults to nil).

    diffingKey

    the diffing key, required for automated diffing.