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
See moreIndexPath, that can be used to locate a given cell orTableSectionin the data set.Declaration
Swift
public struct KeyPath : Equatable -
Enclosing
UICollectionViewthat presents all theTableSectiondata.FunctionalCollectionDatawill take care of setting its ownUICollectionViewDelegateandUICollectionViewDataSourceand manage all the internals of theUICollectionViewon 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
truewhen arenderAndDiffpass 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
nameString 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
keyPathA key path identifying the cell to look up.
Return Value
A
CellConfigTypeinstance corresponding to the key path ornilif the key path is invalid. -
Returns the key path of the cell in a given
IndexPathlocation.Note: This method performs an unsafe lookup, make sure that the
IndexPathexists before trying to transform it into aKeyPath.Declaration
Swift
public func keyPathForIndexPath(indexPath: IndexPath) -> KeyPathParameters
indexPathA 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
newSectionsAn 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.
keyPathThe key path identifying which cell to scroll into view after the render occurs.
animatedtrueto animate the changes to the collection cells, orfalseif theUICollectionViewshould be updated with no animation.completionCallback that will be called on the main thread once the
UICollectionViewhas 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
newSectionsAn 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.
animatedtrueto animate the changes to the collection cells, orfalseif theUICollectionViewshould be updated with no animation.completionCallback that will be called on the main thread once the
UICollectionViewhas 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
keyPathA key path identifying a row in the collection view.
animatedtrueif you want to animate the selection, andfalseif the change should be immediate.scrollPositionAn option that specifies where the item should be positioned when scrolling finishes.
triggerDelegatetrueto trigger thecollection:didSelectItemAt:delegate fromUICollectionVieworfalseto skip it. Skipping it is the defaultUICollectionViewbehavior. -
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
keyPathA key path identifying a row in the collection view.
animatedtrueto animate to the new scroll position, orfalseto scroll immediately.scrollPositionSpecifies where the item specified by
keyPathshould be positioned once scrolling finishes. -
Declaration
Swift
public func keyPath(at point: CGPoint) -> KeyPath?Parameters
pointThe point in the collection view’s bounds that you want to test.
Return Value
The keypath of the item at the specified point, or
nilif no item was found at that point. -
Returns the IndexPath corresponding to the provided KeyPath.
Declaration
Swift
public func indexPathFromKeyPath(_ keyPath: KeyPath) -> IndexPath?Parameters
keyPathThe path representing the desired indexPath.
Return Value
The IndexPath of the item at the provided keyPath.
-
This is an undocumented optional
UIScrollViewDelegatemethod 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)
View on GitHub
FunctionalCollectionData Class Reference