ComponentTree
open class ComponentTree : LithoVisibilityEventsListener, StateUpdater, MountedViewReference, ErrorComponentReceiver, LithoTreeLifecycleProvider
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
interface NewLayoutStateReadyListener
Listener that will be notified when a new LayoutState is computed and ready to be committed to this ComponentTree.
Properties
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
Link copied to clipboard
open fun applyLazyStateUpdatesForContainer(componentKey: String, container: StateContainer, isLayoutState: Boolean): StateContainer
Link copied to clipboard
Link copied to clipboard
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
open fun create(context: ComponentContext, @Nullable root: Component, @Nullable controller: LithoVisibilityEventsController): ComponentTree.Builder
Link copied to clipboard
open fun createNestedComponentTree(parentContext: ComponentContext, @Nullable component: Component): ComponentTree.Builder
Creates a ComponentTree nested inside the ComponentTree of the provided parentContext.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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
Link copied to clipboard
Whether this ComponentTree has been mounted at least once.
Link copied to clipboard
Link copied to clipboard
Returns whether incremental mount is enabled or not in this component.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Removes a state update that was previously enqueued if the state update has not been processed yet.
Link copied to clipboard
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
Link copied to clipboard
open fun setNewLayoutStateReadyListener(@Nullable listener: ComponentTree.NewLayoutStateReadyListener)
Link copied to clipboard
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
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
Link copied to clipboard
Link copied to clipboard
Update the width/height spec.
Same as setSizeSpec but fetches the resulting width/height in the given Size.
Link copied to clipboard
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
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
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.