Renderer

open class Renderer<Updater> where Updater : Updater

Renderer is a controller to render passed data to target immediately using specific adapter and updater.

Its behavior can be changed by using other type of adapter, updater, or by customizing it.

Example for render a section containing simple nodes.

let tableView: UITableView = ...
let renderer = Renderer(
    adapter: UITableViewAdapter(),
    updater: UITableViewUpdater()
)

renderer.target = tableView

renderer.render {
    Label("Cell 1")
        .identified(by: \.text)

    Label("Cell 2")
        .identified(by: \.text)

    Label("Cell 3")
        .identified(by: \.text)
}
  • An instance of adapter that specified at initialized.

    Declaration

    Swift

    public let adapter: Updater.Adapter
  • An instance of updater that specified at initialized.

    Declaration

    Swift

    public let updater: Updater
  • An instance of target that weakly referenced. It will be passed to the prepare method of updater at didSet.

    Declaration

    Swift

    open weak var target: Updater.Target? { get set }
  • Returns a current data held in adapter. When data is set, it renders to the target immediately.

    Declaration

    Swift

    open var data: [Section] { get set }
  • Create a new instance with given adapter and updater.

    Declaration

    Swift

    public init(adapter: Updater.Adapter, updater: Updater)
  • Render given collection of sections, immediately.

    Declaration

    Swift

    open func render<C>(_ data: C) where C : Collection, C.Element == Section

    Parameters

    data

    A collection of sections to be rendered.

  • Render given collection of sections skipping nil, immediately.

    Declaration

    Swift

    open func render<C>(_ data: C) where C : Collection, C.Element == Section?

    Parameters

    data

    A collection of sections to be rendered that can be contains nil.

  • Render given collection sections, immediately.

    Declaration

    Swift

    open func render(_ data: Section...)

    Parameters

    data

    A variadic number of sections to be rendered.

  • Render given variadic number of sections skipping nil, immediately.

    Declaration

    Swift

    open func render(_ data: Section?...)

    Parameters

    data

    A variadic number of sections to be rendered that can be contains nil.

  • Render given variadic number of sections with function builder syntax, immediately.

    Declaration

    Swift

    open func render<S>(@SectionsBuilder sections: () -> S) where S : SectionsBuildable

    Parameters

    sections

    A closure that constructs sections.

  • Render a single section contains given cells with function builder syntax, immediately.

    Declaration

    Swift

    open func render<C>(@CellsBuilder cells: () -> C) where C : CellsBuildable

    Parameters

    cells

    A closure that constructs cells.