AnyComponent

public struct AnyComponent : Component

A type-erased component.

  • The value wrapped by this instance.

    Declaration

    Swift

    @inlinable
    public var base: Any { get }
  • A string used to identify a element that is reusable. Default is the type name of self.

    Declaration

    Swift

    @inlinable
    public var reuseIdentifier: String { get }
  • Create a type-erased component that wraps the given instance.

    Declaration

    Swift

    @inlinable
    public init<Base>(_ base: Base) where Base : Component

    Parameters

    base

    A component to be wrap.

  • Returns a new instance of Content.

    Declaration

    Swift

    @inlinable
    public func renderContent() -> Any

    Return Value

    A new Content instance for render on top of element of list UI element.

  • Render properties into the content on the element of list UI.

    Declaration

    Swift

    @inlinable
    public func render(in content: Any)
  • Returns the referencing size of content to render on the list UI.

    Declaration

    Swift

    @inlinable
    public func referenceSize(in bounds: CGRect) -> CGSize?

    Return Value

    The referencing size of content to render on the list UI. If returns nil, the element of list UI falls back to its default size like UITableView.rowHeight or UICollectionViewFlowLayout.itemSize.

  • Returns a Bool value indicating whether the content should be reloaded.

    Note

    Unlike Equatable, this doesn’t compare whether the two values exactly equal. It’s can be ignore property comparisons, if not expect to reload content.

    Declaration

    Swift

    @inlinable
    public func shouldContentUpdate(with next: AnyComponent) -> Bool

    Return Value

    A Bool value indicating whether the content should be reloaded.

  • Returns a Bool value indicating whether component should be render again.

    Declaration

    Swift

    @inlinable
    public func shouldRender(next: AnyComponent, in content: Any) -> Bool

    Parameters

    next

    The next value to be compared to the receiver.

    content

    An instance of content laid out on the element.

    Return Value

    A Bool value indicating whether the component should be render again.

  • Layout the content on top of element of the list UI.

    Note

    UIView and UIViewController are laid out with edge constraints by default.

    Declaration

    Swift

    @inlinable
    public func layout(content: Any, in container: UIView)

    Parameters

    content

    An instance of content to be laid out on top of element.

    container

    A container view to layout content.

  • The natural size for the passed content.

    Declaration

    Swift

    @inlinable
    public func intrinsicContentSize(for content: Any) -> CGSize

    Return Value

    A CGSize value represents a natural size of the passed content.

  • Invoked every time of before a component got into visible area.

    Declaration

    Swift

    @inlinable
    public func contentWillDisplay(_ content: Any)
  • Invoked every time of after a component went out from visible area.

    Declaration

    Swift

    @inlinable
    public func contentDidEndDisplay(_ content: Any)
  • Returns a base instance casted as given type if possible.

    Declaration

    Swift

    @inlinable
    public func `as`<T>(_: T.Type) -> T?

    Return Value

    A casted base instance.

  • A textual representation of this instance, suitable for debugging.

    Declaration

    Swift

    public var debugDescription: String { get }