ComponentTree

Represents a tree of components and controls their life cycle. ComponentTree takes in a single root component and recursively invokes its OnCreateLayout to create a tree of components. ComponentTree is responsible for refreshing the mounted state of a component with new props.

The usual use case for ComponentTree is: ComponentTree component = ComponentTree.create(context, MyComponent.create()); myHostView.setRoot(component);

Types

Link copied to clipboard
class Builder
A builder class that can be used to create a ComponentTree.
Link copied to clipboard
interface MeasureListener
Link copied to clipboard
Listener that will be notified when a new LayoutState is computed and ready to be committed to this ComponentTree.

Properties

Link copied to clipboard
val INVALID_ID: Int = -1
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Provides a new instance of the TreeState that is initialized with the TreeState held by the ComponentTree.
Link copied to clipboard
The provided measureListener will be called when a valid layout is commited.
Link copied to clipboard
open fun applyLazyStateUpdatesForContainer(componentKey: String, container: StateContainer, isLayoutState: Boolean): StateContainer
Link copied to clipboard
Link copied to clipboard
open fun <T> canSkipStateUpdate(globalKey: String, hookStateIndex: Int, @Nullable newValue: T, isLayoutState: Boolean): Boolean
open fun <T> canSkipStateUpdate(newValueFunction: (in T) -> out T, globalKey: String, hookStateIndex: Int, isLayoutState: Boolean): Boolean
Link copied to clipboard
open fun checkWorkingRangeAndDispatch(position: Int, firstVisibleIndex: Int, lastVisibleIndex: Int, firstFullyVisibleIndex: Int, lastFullyVisibleIndex: Int)
Check if the any child components stored in LayoutState have entered/exited the working range, and dispatch the event to trigger the corresponding registered methods.
Link copied to clipboard
Link copied to clipboard

Creates a ComponentTree nested inside the ComponentTree of the provided parentContext.
Link copied to clipboard
open fun getCachedValue(globalKey: String, index: Int, cachedValueInputs: Any, isLayoutState: Boolean): Any
Returns a Cached value that is accessible across all re-render operations.
Link copied to clipboard
Link copied to clipboard
open fun getEventTrigger(handle: Handle, methodId: Int): EventTrigger
Link copied to clipboard
open fun getId(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getLogger(): ComponentsLogger
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Retrieves the tree property associated with the given key, if it exists in this
Link copied to clipboard
Link copied to clipboard
open fun hasCompatibleLayout(widthSpec: Int, heightSpec: Int): Boolean
Link copied to clipboard
open fun hasMounted(): Boolean
Whether this ComponentTree has been mounted at least once.
Link copied to clipboard
open fun isFirstMount(): Boolean
Link copied to clipboard
Returns whether incremental mount is enabled or not in this component.
Link copied to clipboard
open fun isReleased(): Boolean
Link copied to clipboard
open fun onErrorComponent(component: Component)
Link copied to clipboard
open fun putCachedValue(globalKey: String, index: Int, cachedValueInputs: Any, cachedValue: Any, isLayoutState: Boolean)
Stores a Cached value that will be accessible across all re-render operations.
Link copied to clipboard
open fun release()
The contract is that in order to release a ComponentTree, you must do so from the main thread.
Link copied to clipboard
open fun removePendingStateUpdate(key: String, nestedTreeContext: Boolean)
Removes a state update that was previously enqueued if the state update has not been processed yet.
Link copied to clipboard
open fun setDebugLogsBreadcrumb(@Nullable breadcrumb: String)
This method associates this ComponentTree debug logs with the given String This allows you to create an association of the ComponentTree with any identifier or sorts that enables you to trace the logs of this ComponentTree with the identifier.
Link copied to clipboard
open fun setFirstMount(isFirstMount: Boolean)
Link copied to clipboard
open fun setRoot(@Nullable root: Component)
Update the root component.
Link copied to clipboard
open fun setRootAndSizeSpecAsync(@Nullable root: Component, widthSpec: Int, heightSpec: Int)
Compute asynchronously a new layout with the given component root and sizes
open fun setRootAndSizeSpecAsync(@Nullable root: Component, widthSpec: Int, heightSpec: Int, @Nullable treePropContainer: TreePropContainer)
Compute asynchronously a new layout with the given component root, sizes and stored TreePropContainer.
Link copied to clipboard
open fun setRootAndSizeSpecSync(@Nullable root: Component, widthSpec: Int, heightSpec: Int)
Compute a new layout with the given component root and sizes
open fun setRootAndSizeSpecSync(@Nullable root: Component, widthSpec: Int, heightSpec: Int, @Nullable output: Size)
open fun setRootAndSizeSpecSync(@Nullable root: Component, widthSpec: Int, heightSpec: Int, @Nullable output: Size, @Nullable treePropContainer: TreePropContainer)
Link copied to clipboard
open fun setRootAsync(@Nullable root: Component)
Link copied to clipboard
open fun setRootSync(@Nullable root: Component)
Link copied to clipboard
open fun setSizeSpec(widthSpec: Int, heightSpec: Int)
Update the width/height spec.
open fun setSizeSpec(widthSpec: Int, heightSpec: Int, @Nullable output: Size)
Same as setSizeSpec but fetches the resulting width/height in the given Size.
Link copied to clipboard
open fun setSizeSpecAsync(widthSpec: Int, heightSpec: Int)
Link copied to clipboard
open fun setVersionedRootAndSizeSpec(@Nullable root: Component, widthSpec: Int, heightSpec: Int, @Nullable output: Size, @Nullable treePropContainer: TreePropContainer, externalRootVersion: Int)
Link copied to clipboard
open fun setVersionedRootAndSizeSpecAsync(@Nullable root: Component, widthSpec: Int, heightSpec: Int, @Nullable output: Size, @Nullable treePropContainer: TreePropContainer, externalRootVersion: Int)
Link copied to clipboard
fun updateHookStateAsync(globalKey: String, updater: HookUpdater, attribution: String, isLayoutState: Boolean)
Same as updateStateAsync but for Hook State.
Link copied to clipboard
fun updateHookStateSync(globalKey: String, updater: HookUpdater, attribution: String, isLayoutState: Boolean)
Same as updateStateSync but for Hook State.
Link copied to clipboard
open fun updateLayoutThreadHandler(@Nullable layoutThreadHandler: RunnableHandler)
Provide custom RunnableHandler.
Link copied to clipboard
open fun updateStateAsync(componentKey: String, stateUpdate: StateContainer.StateUpdate, attribution: String)

open fun updateStateAsync(componentKey: String, 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 fun updateStateLazy(componentKey: String, stateUpdate: StateContainer.StateUpdate, isLayoutState: Boolean)
Enqueues a state update that will not schedule a new render.
Link copied to clipboard
open fun updateStateSync(componentKey: String, 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.