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
A builder class that can be used to create a ComponentTree.
Listener that will be notified when a new LayoutState is computed and ready to be committed to this ComponentTree.
Properties
The default TreeState needed by the StateProvider when there's no active scope in flight.
Property accessor for effectHandler, for backward compatibility with test code.
Whether this updater implements the same-frame animation invalidation path.
Returns whether incremental mount is enabled or not in this component.
Kotlin property alias for _mainThreadLayoutState.
Kotlin property for accessing and setting the root component.
The default stable TreeState needed by the StateProvider as a fallback for UI thread reads when there's no active scope in flight.
Functions
Transfers this tree's LithoSaveableStateRegistry to the caller so it can be supplied to a replacement tree with Builder.withLithoSaveableStateRegistry. The caller becomes responsible for closing the registry when the logical UI scope ends. Returns null when the tree has no saveable-state owner.
Provides a new instance of the TreeState that is initialized with the committed TreeState held by the ComponentTree.
The provided measureListener will be called when a valid layout is committed.
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.
The layouts which this ComponentTree was currently calculating will be terminated before a valid result is computed. It's not safe to try to compute any layouts for this ComponentTree after that because it's in an incomplete state, so it needs to be released.
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.
Returns a Cached value that is accessible across all re-render operations.
Retrieves the tree property associated with the given key, if it exists in this ComponentTree
Whether this ComponentTree has been mounted at least once.
Stores a Cached value that will be accessible across all re-render operations.
Removes a previously-added listener. Providers that never retain listeners may no-op.
Removes a state update that was previously enqueued if the state update has not been processed yet.
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.
Compute asynchronously a new layout with the given component root and sizes
Compute asynchronously a new layout with the given component root, sizes and stored TreePropContainer.
Compute a new layout with the given component root and sizes
Update the width/height spec. This is useful if you are currently detached and are responding to a configuration change. If you are currently attached then the HostView is the source of truth for width/height, so this call will be ignored.
Same as setSizeSpec but fetches the resulting width/height in the given Size.
Same as updateStateAsync but for Hook State.
Same as updateStateSync but for Hook State.
Provide custom RunnableHandler. If null is provided default one will be used for layouts.
Enqueues a state update that will schedule a new render on a Thread controlled by the Litho infrastructure.
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.
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.