LithoRenderer

class LithoRenderer(val context: Context, val id: Int = LithoTree.generateComponentTreeId(), val componentsConfig: ComponentsConfiguration = ComponentsConfiguration.defaultInstance, val renderUnitIdGenerator: RenderUnitIdGenerator = RenderUnitIdGenerator(id), val treeState: TreeState? = TreeState(), val parentTreePropContainer: TreePropContainer? = TreePropContainer(), val treePropContainer: TreePropContainer? = TreePropContainer(), runnableHandlerProvider: RunnableHandlerProvider = ComponentTree.DefaultLayoutHandlerProvider(), val visibilityController: LithoVisibilityEventsController? = null, val synchronizer: UpdateSynchronizer? = null) : TreeStateProvider, StateUpdater, StateUpdateRequester, MountedViewReference, ErrorComponentReceiver

A renderer for Litho components that handles RESOLVE and LAYOUT.

Constructors

Link copied to clipboard
constructor(context: Context, id: Int = LithoTree.generateComponentTreeId(), componentsConfig: ComponentsConfiguration = ComponentsConfiguration.defaultInstance, renderUnitIdGenerator: RenderUnitIdGenerator = RenderUnitIdGenerator(id), treeState: TreeState? = TreeState(), parentTreePropContainer: TreePropContainer? = TreePropContainer(), treePropContainer: TreePropContainer? = TreePropContainer(), runnableHandlerProvider: RunnableHandlerProvider = ComponentTree.DefaultLayoutHandlerProvider(), visibilityController: LithoVisibilityEventsController? = null, synchronizer: UpdateSynchronizer? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The default TreeState needed by the StateProvider when there's no active scope in flight.

Link copied to clipboard
Link copied to clipboard
val id: Int
Link copied to clipboard

Whether this updater implements the same-frame animation invalidation path.

Link copied to clipboard
open override var isFirstMount: Boolean
Link copied to clipboard
open override val mountedView: View?
Link copied to clipboard
var sizeConstraints: SizeConstraints?

The size constraints used for layout calculations.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val uiTreeState: TreeState?

The default stable TreeState needed by the StateProvider as a fallback for UI thread reads when there's no active scope in flight.

Functions

Link copied to clipboard

Applies a batch of animation-frame invalidations produced during a single AnimationController frame tick. Each invalidation re-renders the read-tracked consumers of its stateId; the animated value itself stays owned by its AnimatedValue.

Link copied to clipboard
open override fun applyLazyStateUpdatesForContainer(globalKey: GlobalKey, container: StateContainer, isLayoutState: Boolean): StateContainer
Link copied to clipboard
fun bindTo(host: Host)
Link copied to clipboard
open override fun <T> canSkipStateUpdate(stateId: StateId, newValue: T?, isLayoutState: Boolean): Boolean
open override fun <T> canSkipStateUpdate(newValueFunction: (T) -> T, stateId: StateId, isLayoutState: Boolean): Boolean
Link copied to clipboard

Cleans up any pending resolve or layout operations and resets the renderer state.

Link copied to clipboard
open override fun getCachedValue(cacheKey: HookGlobalKey, cachedValueInputs: Any, isLayoutState: Boolean): Any?

Returns a Cached value that is accessible across all re-render operations.

Link copied to clipboard
open override fun getEventTrigger(key: Any): EventTrigger<*>?
open override fun getEventTrigger(handle: Handle, id: Int): EventTrigger<*>?
Link copied to clipboard
fun layout(constraints: SizeConstraints)

Performs an asynchronous layout calculation with the given constraints. Uses the current resolve result if available, otherwise performs an async resolve first.

Link copied to clipboard
fun layoutSync(constraints: SizeConstraints): LayoutState

Performs a synchronous layout calculation with the given constraints. Uses the current resolve result if available, otherwise performs an inline resolve.

Link copied to clipboard
open override fun onErrorComponent(component: Component?)
Link copied to clipboard
open override fun putCachedValue(cacheKey: HookGlobalKey, cachedValueInputs: Any, cachedValue: Any?, isLayoutState: Boolean)

Stores a Cached value that will be accessible across all re-render operations.

Link copied to clipboard
open override fun removePendingStateUpdate(key: GlobalKey, isLayoutState: Boolean)

Removes a state update that was previously enqueued if the state update has not been processed yet.

Link copied to clipboard
fun render(root: Component, constraints: SizeConstraints)

Performs an asynchronous resolution and layout in one call, which is a non-blocking operation.

Link copied to clipboard
fun renderAsyncKeepingCommittedLayout(root: Component, constraints: SizeConstraints, postAtFront: Boolean = false): Boolean

Shows the last committed layout if it was computed for constraints and renders root in the background, unless that layout is already for root. Returns false when nothing compatible can be shown, in which case the caller must render synchronously.

Link copied to clipboard
fun renderSync(root: Component, constraints: SizeConstraints): LayoutState

Performs a synchronous resolution and layout in one call. This is a blocking operation that completes the entire rendering pipeline.

Link copied to clipboard
fun renderSyncWithCompatibilityChecks(root: Component, sizeConstraint: SizeConstraints)
Link copied to clipboard
open override fun request(update: PendingStateUpdate)
Link copied to clipboard
fun resolve(root: Component)

Initiates an asynchronous resolution process for a component.

Link copied to clipboard
Link copied to clipboard
open override fun updateHookStateAsync(stateId: StateId, updateBlock: HookUpdater, attribution: String?, isLayoutState: Boolean)

Same as updateStateAsync but for Hook State.

Link copied to clipboard
open override fun updateHookStateSync(stateId: StateId, updateBlock: HookUpdater, attribution: String?, isLayoutState: Boolean)

Same as updateStateSync but for Hook State.

Link copied to clipboard
open override fun updateStateAsync(globalKey: GlobalKey, stateUpdate: StateContainer.StateUpdate, attribution: String?, isLayoutState: Boolean)

Enqueues a state update that will schedule a new render on a Thread controlled by the Litho infrastructure.

Link copied to clipboard
open override fun updateStateLazy(globalKey: GlobalKey, stateUpdate: StateContainer.StateUpdate, isLayoutState: Boolean)

Enqueues a state update that will not schedule a new render. The new state will immediately be visible in Event Handlers and it will be visible in the next render phase.

Link copied to clipboard
open override fun updateStateSync(globalKey: GlobalKey, stateUpdate: StateContainer.StateUpdate, attribution: String?, isLayoutState: Boolean)

Enqueues a state update that will schedule a new render on the calling thread at the end of its current run-loop. It is expected that the calling thread has an active Looper.