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
See moreIndexPath
, that can be used to locate a given cell orTableSection
in the data set.Declaration
Swift
public struct KeyPath
-
Enclosing
UITableView
that presents all theTableSection
data.FunctionalTableData
will take care of setting its ownUITableViewDelegate
andUITableViewDataSource
and manage all the internals of theUITableView
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 arenderAndDiff
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 ornil
if the key path is invalid. -
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 aKeyPath
.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, orfalse
if theUITableView
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, orfalse
if theUITableView
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, andfalse
if the change should be immediate.triggerDelegate
true
to trigger thetableView:didSelectRowAt:
delegate fromUITableView
orfalse
to skip it. Skipping it is the defaultUITableView
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, orfalse
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)