FunctionalTableData

public class FunctionalTableData : NSObject

A renderer for UITableView.

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

  • A type that provides the information about an exception.

    Declaration

    Swift

    public struct Exception
  • Specifies the desired exception handling behaviour.

    Declaration

    Swift

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

    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
  • Enclosing UITableView that presents all the TableSection data.

    FunctionalTableData will take care of setting its own UITableViewDelegate and UITableViewDataSource and manage all the internals of the UITableView on its own.

    Declaration

    Swift

    public var tableView: UITableView? { 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 table as an accessibility aid. See UIScrollView’s documentation for more information.

    Declaration

    Swift

    public var scrollViewAccessibilityScrollStatus: ((UIScrollView) -> String?)?
  • The type of animation when rows and sections are inserted or deleted.

    Declaration

    Swift

    public struct TableAnimations
  • A Boolean value that returns true when a renderAndDiff pass is currently running.

    Declaration

    Swift

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

    Declaration

    Swift

    public init(name: String? = nil)

    Parameters

    name

    String identifying this instance of FunctionalTableData, useful when several instances are displayed on the same screen. This value also 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.

  • Returns the drawing area for a row identified by key path.

    Declaration

    Swift

    public func rectForKeyPath(_ keyPath: KeyPath) -> CGRect?

    Parameters

    keyPath

    A key path identifying the cell to look up.

    Return Value

    A rectangle defining the area in which the table view draws the row or nil if the key path is invalid.

  • Populates the table with the specified sections, and asynchronously updates the table 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, animations: TableAnimations = .default, completion: (() -> Void)? = nil)

    Parameters

    newSections

    An array of TableSection instances to populate the table 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 table cells, or false if the UITableView should be updated with no animation.

    animations

    Type of animation to perform. See FunctionalTableData.TableAnimations for more info.

    completion

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

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

    Declaration

    Swift

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

    Parameters

    newSections

    An array of TableSection instances to populate the table 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 table cells, or false if the UITableView should be updated with no animation.

    animations

    Type of animation to perform. See FunctionalTableData.TableAnimations for more info.

    completion

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

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

    Declaration

    Swift

    public func select(keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableView.ScrollPosition = .none, triggerDelegate: Bool = false)

    Parameters

    keyPath

    A key path identifying a row in the table view.

    animated

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

    triggerDelegate

    true to trigger the tableView:didSelectRowAt: delegate from UITableView or false to skip it. Skipping it is the default UITableView behavior.

  • Scrolls to the item at the specified key path.

    Declaration

    Swift

    public func scroll(to keyPath: KeyPath, animated: Bool = true, scrollPosition: UITableView.ScrollPosition = .bottom)

    Parameters

    keyPath

    A key path identifying a row in the table 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.

  • 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)