DataProvider

public protocol DataProvider : AnyObject

DataProvider provides data in a way which is related to UITableViewDataSource or UICollectionViewDataSource. It is generic over Object, which is the kind of data it provides.

See also

AnyDataProvider
  • Element is the kind of data DataProvider provides.

    Declaration

    Swift

    associatedtype Element
  • An observable where one can subscribe to changes of data provider.

    Declaration

    Swift

    var observable: DataProviderObservable { get }
  • Returns an object for a given index path.

    Declaration

    Swift

    func object(at indexPath: IndexPath) -> Element

    Parameters

    indexPath

    the index path to get the object for.

    Return Value

    the object at the given index path.

  • Returns the number of items in a given section.

    Declaration

    Swift

    func numberOfItems(inSection section: Int) -> Int

    Parameters

    section

    the section.

    Return Value

    number of items in the given section.

  • Return the number of sections.

    Declaration

    Swift

    func numberOfSections() -> Int

    Return Value

    the number of sections.

  • safeAccessToObject(at:) Extension method

    Returns an object for a given index path. If the index path is out of range, nil gets returned.

    Declaration

    Swift

    public func safeAccessToObject(at indexPath: IndexPath) -> Element?

    Parameters

    indexPath

    the index path to get the object for.

    Return Value

    the object at the given index path.

  • lazyTransform(_:) Extension method

    Lazy transforms the content with a given closure into a new data provider.

    Declaration

    Swift

    public func lazyTransform<TargetType>(_ transform: @escaping (Element) -> TargetType) ->
        LazyTransformationDataProvider<TargetType>

    Parameters

    transform

    the closure which transforms the element into the target value

    Return Value

    a LazyTransformationDataProvider which provides newly transformed objects.