FunctionalCollectionData

public class FunctionalCollectionData : NSObject

A renderer for UICollectionView.

By providing a complete description of your view state using an array of TableSection. FunctionalCollectionData compares it with the previous render call to insert, update, and remove everything that have changed. This massively simplifies state management of complex UI.

  • Specifies the desired exception handling behaviour.

    Declaration

    Swift

    public static var exceptionHandler: FunctionalTableDataExceptionHandler?
  • Represents the unique path to a given item in the FunctionalCollectionData.

    Think of it as a readable implementation of IndexPath, that can be used to locate a given cell or TableSection in the data set.

    See more

    Declaration

    Swift

    public struct KeyPath : Equatable
  • Enclosing UICollectionView that presents all the TableSection data.

    FunctionalCollectionData will take care of setting its own UICollectionViewDelegate and UICollectionViewDataSource and manage all the internals of the UICollectionView on its own.

    Declaration

    Swift

    public var collectionView: UICollectionView? { get set }
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewDidScroll: ((UIScrollView) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewWillBeginDragging: ((UIScrollView) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewWillEndDragging: ((UIScrollView, CGPoint, UnsafeMutablePointer<CGPoint>) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewDidEndDragging: ((UIScrollView, Bool) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewWillBeginDecelerating: ((UIScrollView) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewDidEndDecelerating: ((UIScrollView) -> Void)?
  • Tells the delegate that the scroll view has changed its content size.

    Declaration

    Swift

    public var scrollViewDidChangeContentSize: ((UIScrollView) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewDidEndScrollingAnimation: ((UIScrollView) -> Void)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewShouldScrollToTop: ((UIScrollView) -> Bool)?
  • See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewDidScrollToTop: ((UIScrollView) -> Void)?
  • An optional callback that describes the current scroll position of the collection view as an accessibility aid. See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewAccessibilityScrollStatus: ((UIScrollView) -> String?)?
  • A Boolean value that returns true when a renderAndDiff pass is currently running.

    Declaration

    Swift

    public var isRendering: Bool { get }
  • Initializes a FunctionalCollectionData. To configure its view, provide a UICollectionView after initialization.

    Declaration

    Swift

    public init(name: String? = nil)

    Parameters

    name

    String identifying this instance of FunctionalCollectionData, useful when several instances are displayed on the same screen. This also value names the queue doing all the rendering work, useful for debugging.

  • Returns the cell identified by a key path.

    Declaration

    Swift

    public func rowForKeyPath(_ keyPath: KeyPath) -> CellConfigType?

    Parameters

    keyPath

    A key path identifying the cell to look up.

    Return Value

    A CellConfigType instance corresponding to the key path or nil if the key path is invalid.

  • Returns the key path specified by its string presentation.

    Declaration

    Swift

    public func keyPathForRowKey(_ key: String) -> KeyPath?

    Parameters

    key

    String identifier to lookup.

    Return Value

    A KeyPath that matches the key or nil if there is no match.

  • Returns the key path of the cell in a given IndexPath location.

    Note: This method performs an unsafe lookup, make sure that the IndexPath exists before trying to transform it into a KeyPath.

    Declaration

    Swift

    public func keyPathForIndexPath(indexPath: IndexPath) -> KeyPath

    Parameters

    indexPath

    A key path identifying where the key path is located.

    Return Value

    The key representation of the supplied IndexPath.

  • Populates the collection with the specified sections, and asynchronously updates the collection view to reflect the cells and sections that have changed.

    Declaration

    Swift

    @available(*, deprecated, message: "Call `scroll(to:animated:scrollPosition:﹚` in the completion handler instead.")
    public func renderAndDiff(_ newSections: [TableSection], keyPath: KeyPath?, animated: Bool = true, completion: (() -> Void)? = nil)

    Parameters

    newSections

    An array of TableSection instances to populate the collection with. These will replace the previous sections and update any cells that have changed between the old and new sections.

    keyPath

    The key path identifying which cell to scroll into view after the render occurs.

    animated

    true to animate the changes to the collection cells, or false if the UICollectionView should be updated with no animation.

    completion

    Callback that will be called on the main thread once the UICollectionView has finished updating and animating any changes.

  • Populates the collection with the specified sections, and asynchronously updates the collection view to reflect the cells and sections that have changed.

    Declaration

    Swift

    public func renderAndDiff(_ newSections: [TableSection], animated: Bool = true, completion: (() -> Void)? = nil)

    Parameters

    newSections

    An array of TableSection instances to populate the collection with. These will replace the previous sections and update any cells that have changed between the old and new sections.

    animated

    true to animate the changes to the collection cells, or false if the UICollectionView should be updated with no animation.

    completion

    Callback that will be called on the main thread once the UICollectionView has finished updating and animating any changes.

  • Selects a row in the collection view identified by a key path.

    Declaration

    Swift

    public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionView.ScrollPosition = [], triggerDelegate: Bool = false)

    Parameters

    keyPath

    A key path identifying a row in the collection view.

    animated

    true if you want to animate the selection, and false if the change should be immediate.

    scrollPosition

    An option that specifies where the item should be positioned when scrolling finishes.

    triggerDelegate

    true to trigger the collection:didSelectItemAt: delegate from UICollectionView or false to skip it. Skipping it is the default UICollectionView behavior.

  • Scrolls to the item at the specified key path.

    Declaration

    Swift

    public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UICollectionView.ScrollPosition = [.bottom, .right])

    Parameters

    keyPath

    A key path identifying a row in the collection view.

    animated

    true to animate to the new scroll position, or false to scroll immediately.

    scrollPosition

    Specifies where the item specified by keyPath should be positioned once scrolling finishes.

  • Declaration

    Swift

    public func keyPath(at point: CGPoint) -> KeyPath?

    Parameters

    point

    The point in the collection view’s bounds that you want to test.

    Return Value

    The keypath of the item at the specified point, or nil if no item was found at that point.

  • Returns the IndexPath corresponding to the provided KeyPath.

    Declaration

    Swift

    public func indexPathFromKeyPath(_ keyPath: KeyPath) -> IndexPath?

    Parameters

    keyPath

    The path representing the desired indexPath.

    Return Value

    The IndexPath of the item at the provided keyPath.

  • This is an undocumented optional UIScrollViewDelegate method that is not exposed by the public protocol but will still get called on delegates that implement it. Because it is not publicly exposed, the Swift 4 compiler will not automatically annotate it as @objc, requiring this manual annotation.

    Declaration

    Swift

    @objc
    public func scrollViewDidChangeContentSize(_ scrollView: UIScrollView)