Package-level declarations

Types

Link copied to clipboard

A list of all roles used for accessibility. There is no API for these in Android yet, so roles are currently based off of the class being rendered. These roles are defined by Google's TalkBack screen reader, and this list should be kept up to date with their implementation.

Link copied to clipboard
Link copied to clipboard
class ActionAttributeKey<T>(description: String) : AttributeKey<T>

This type of key is used to represent an attribute that reflects an Action (such as click, long click, etc).

Link copied to clipboard
object Animations
Link copied to clipboard

Utilities for animations debug.

Link copied to clipboard

This abstraction allows us to retrieve a LifecycleOwner. This class is meant to be used to identify the closest LifecycleOwner and associate it to the ComponentTree.

Link copied to clipboard

This LithoVisibilityEventsController implementation dispatches to the registered observers the lifecycle state changes triggered by the provided LifecycleOwner. For example, if a Fragment is passed as param, the observers will be registered to listen to all of the fragment's lifecycle state changes.

Link copied to clipboard
interface Attachable

Interface for something (e.g. a Component or a useEffect registration) which should receive callbacks when it is attached/detached from the tree.

Link copied to clipboard

Manages dispatching attach/detach events to a set of Attachable.

Link copied to clipboard
open class AttributeKey<T>(val description: String)

This abstraction is used as an identifier for a given attribute of type T. Attributes are used for testing purposes, allowing the clients to filter and assert on Component according to them.

Link copied to clipboard

Defines an abstraction that knows how to store attributes.

Link copied to clipboard

Simple holder which allows to store and retrieve attributes.

Link copied to clipboard
abstract class BaseMountingView : ComponentHost, RenderCoreExtensionHost, AnimatedRootHost
Link copied to clipboard

A Batched State Update Strategy will define when do we schedule a final state update and corresponding layout calculation, so that we can enqueue the most reasonable number of state updates without incurring with an excessive number of layout calculations.

Link copied to clipboard
Link copied to clipboard
class Border : Equivalence<Border>

Represents a collection of attributes that describe how a border should be applied to a layout

Link copied to clipboard
class BoundaryWorkingRange @JvmOverloads constructor(offset: Int = OFFSET) : WorkingRange

An implementation of working range that uses offset to define the upper bound and the lower boundary. If the position is inside the boundary, it's in the range, otherwise it's out of the range.

Link copied to clipboard
Link copied to clipboard
typealias ClassValuePair<T> = Pair<Class<T>, T>

Defines a single tree prop, i.e. a mapping from type to concrete instance of that type that is visible to the subtree, to be used with TreePropProvider.

Link copied to clipboard
fun interface CleanupFunc

Interface for the onCleanup function: use onCleanup to define the cleanup function for your useEffect hook.

Link copied to clipboard
open class ClickEvent
Components should implement an event of this type in order to receive Android click events.
Link copied to clipboard

Provides util methods for common collection patterns.

Link copied to clipboard

A Component that renders its children in a column.

Link copied to clipboard
class CommonProps : LayoutProps, Equivalence<CommonProps?>

Internal class that holds props that are common to all Components.

Link copied to clipboard
abstract class Component : Cloneable, Equivalence<T> , AttributesAcceptor
Represents a unique instance of a component.
Link copied to clipboard
open class ComponentContext
A Context subclass for use within the Components framework.
Link copied to clipboard
Link copied to clipboard

Focus change listener that triggers its underlying event handler.

Link copied to clipboard
open class ComponentHost : Host, DisappearingHost
A ViewGroup that can host the mounted state of a Component.
Link copied to clipboard
Link copied to clipboard
interface ComponentLayout

Represents a Component's computed layout state. The computed bounds will be used by the framework to define the size and position of the component's mounted android.view.Views and android.graphics.drawable.Drawables returned by com.facebook.litho.annotations.OnMeasure.

Link copied to clipboard

Long click listener that triggers its underlying event handler.

Link copied to clipboard
class ComponentResolveResult(val lithoNode: LithoNode?, val commonProps: CommonProps?)

The result of a Component#resolveWithResult call. This will hold the LithoNode this Component resolved to as well as CommonProps of this component.

Link copied to clipboard
open class ComponentScope(val context: ComponentContext, resolveContext: ResolveContext? = null) : ResourcesScope

The implicit receiver for KComponent.render call. This class exposes the ability to use hooks, like useState, and convenience functions, like dp.

Link copied to clipboard

This is intended as a hook into android.util.Log, but allows you to provide your own functionality. Use it as ComponentsReporter.emitMessage(level, message); As a default, it simply calls android.util.Log (see DefaultComponentsReporter). You may supply your own with ComponentsReporter.provide.

Link copied to clipboard

This is intended as a hook into android.os.Trace, but allows you to provide your own functionality. Use it as

Link copied to clipboard

Touch listener that triggers its underlying event handler.

Link copied to clipboard
Represents a tree of components and controls their life cycle.
Link copied to clipboard

This is used as a listener for events that happen on the scope of a given ComponentTree. These events can be related with both the render UI pipeline, or with the view-side events created by rendercore in the LithoView that is associated to the ComponentTree to which this listener observes.

Link copied to clipboard

Helper class in charge of dumping the component hierarchy related to a provided ComponentContext

Link copied to clipboard
open class ComponentUtils
Link copied to clipboard
annotation class ContainerDsl

Marker for the Litho container component DSL. This makes sure that when we have scope-specific functions like child() to add children, they can only apply to the closest receiver annotated with ContainerDsl.

Link copied to clipboard
class ContentPreAllocator(treeId: Int, componentContext: ComponentContext, mountContentHandler: RunnableHandler, avoidRedundantPreAllocations: Boolean, logger: ComponentsLogger?, nodeSupplier: () -> List<RenderTreeNode>, preAllocator: (Context, ContentAllocator<*>) -> Boolean)

Pre-allocate the mount content of all MountSpec in the given ComponentTree.

Link copied to clipboard
Link copied to clipboard

A DebugComponent represents a node in Litho's component hierarchy. DebugComponent removes the need to worry about implementation details of whether a node is represented by a [ ] or a ComponentLayout. The purpose of this class is for tools such as Flipper's UI inspector to be able to easily visualize a component hierarchy without worrying about implementation details of Litho.

Link copied to clipboard

Describes DebugComponents for use in testing and debugging. Note that com.facebook.litho.config.ComponentsConfiguration#isEndToEndTestRun must be enabled in order for this data to be collected.

Link copied to clipboard

DebugHierarchy provides a light(er) weight way to track and access information about the component parentage of a given com.facebook.rendercore.MountItem. For a given com.facebook.rendercore.MountItem, it provides access to a linked list of Class objects representing the class of the Component and each of it's hierarchy parents.

Link copied to clipboard

A DebugLayoutNode is a wrapper around InternalNode which allows debug tools to inspect and mutate internal nodes without making InternalNode a public class. This class should never be used in production and only for building debug tools.

Link copied to clipboard
Link copied to clipboard
open class DefaultComponentsReporter : ErrorReporterDelegate
Link copied to clipboard
open class DefaultComponentsSystrace : Systracer
Link copied to clipboard
Link copied to clipboard
Default implementation of ErrorEvent handler.
Link copied to clipboard
An event handler that takes two event handlers and calls both of them when an event is dispatched.
Link copied to clipboard
Defines a tooltip that can be passed to the ComponentTree to be anchored to a component.
Link copied to clipboard

Allows a new DynamicValue to be derived from an existing DynamicValue, with modifications applied.

Link copied to clipboard
class Diff<T>(val previous: T?, var next: T?)

Represents a diff between two T values. It should be used when defining the ShouldUpdate callback in a ComponentSpec and may be used in OnCreateTransition to define animations based on incoming changes. A Diff holds the previous and next value for a specific Prop or State for a ComponentSpec.

Link copied to clipboard
interface DiffNode : Cloneable

A lightweight representation of a layout node, used to cache measurements between two Layout tree calculations.

Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to dispatchPopulateAccessibilityEvent
Link copied to clipboard
typealias DrawableBinder = RenderUnit.Binder<Any?, Drawable, Any?>
Link copied to clipboard
Link copied to clipboard
Static class containing a factory method for creating a matrix to apply to a drawable.
Link copied to clipboard
open class DynamicPropsExtension : MountExtension<Input, State> , OnItemCallbacks<State>
Link copied to clipboard
Link copied to clipboard
Takes care of dynamic Props Usage from DynamicPropsExtensionUnique per DynamicPropsExtension instance, which calls onBindComponentToContent and {#link onUnbindComponent} when it binds and unbinds Components respectively.
Link copied to clipboard
open class DynamicValue<T>(initialValue: T)

Class represents a DynamicValue, and provides users with ability to change the value, by exposing one public method set It also allows attaching listeners (package level access), and takes care of notifying them when the held value changes.

Link copied to clipboard
class DynamicValueOutput(val component: Component, val scopedContext: ComponentContext?, val commonDynamicProps: SparseArray<out DynamicValue<*>>)
Link copied to clipboard
open class Edges : Equivalence<T>
Link copied to clipboard

A component which renders nothing.

Link copied to clipboard
class EndToEndTestingExtension(mountDelegateTarget: MountDelegateTarget) : MountExtension<EndToEndTestingExtension.EndToEndTestingExtensionInput, Void?>
Link copied to clipboard

Temporary internal settings augmenting com.facebook.litho.config.ComponentsConfiguration. This only exists to circumvent some circular dependency issues that arise by placing this in the .config namespace. Please be aware that this will go away soon. (T30053822)

Link copied to clipboard

An interfaced used by ComponentContext to notify the holder of a Litho hierarchy that as a result of error handling the root of the tree should change to a Litho component representing the error.

Link copied to clipboard
open class ErrorEvent
An event used internally to propagate exceptions up the hierarchy.
Link copied to clipboard

This class is an error event handler that clients can optionally set on a ComponentTree to gracefully handle uncaught/unhandled exceptions thrown from the framework while resolving a layout.

Link copied to clipboard
fun interface EventDispatcher

A class implementing this fun interface will expose a method to dispatch an com.facebook.litho.annotations.Event given an EventHandler.

Link copied to clipboard

Plugin style that can be used for instrument before & after the event is dispatched by EventDispatcher.dispatchOnEvent

Link copied to clipboard
class EventDispatchInfo(var hasEventDispatcher: HasEventDispatcher? = null, var componentContext: ComponentContext? = null)

Holds onto the mutable data used to dispatch an event. This data is kept up-to-date with the latest version of the owning component or section by EventHandlersController.

Link copied to clipboard
open class EventHandler<E> : Function<ReturnType> , Equivalence<T>
Link copied to clipboard

Controller which makes sure EventHandler instances are bound to the latest instance of the Component/Section that created them.

Link copied to clipboard
class EventTrigger<E>(parentKey: String, val id: Int, childKey: String, val handle: Handle?)

Allows a top-down communication with a component and its immediate parent. The component must be able to handle com.facebook.litho.annotations.OnTrigger events in order to accept an EventTrigger.

Link copied to clipboard
Keeps all valid instances of EventTrigger from the hierarchy when the layout is completed
Link copied to clipboard

A class implementing this fun interface wll expose a method annotated with com.facebook.litho.annotations.OnTrigger to accept an com.facebook.litho.annotations.Event given an EventTrigger

Link copied to clipboard
class ExecutorLithoHandler(executor: Executor) : RunnableHandler

A LithoHandler implementation that runs all layout computations against the provided Executor. This LithoHandler can be used in apps that have a well established threading model and need to run layout against one of their already available executors.

Link copied to clipboard
class FlexboxContainerScope(val context: ComponentContext, children: MutableList<Component> = mutableListOf()) : ResourcesScope

The implicit receiver for the trailing lambda on ResourcesScope.Column or ResourcesScope.Row. The receiver gives the ability to add children to this container.

Link copied to clipboard
Event triggered when focus changes on a Component.
Link copied to clipboard
class Handle

Instances of this class are used to uniquely identify Components for triggering external events including showing a LithoTooltip or triggering an com.facebook.litho.annotations.OnTrigger event.

Link copied to clipboard
fun interface HasEventDispatcher

A class implementing this interface will expose a method to retrieve an EventDispatcher.

Link copied to clipboard
fun interface HasEventTrigger

A class implementing this fun interface will expose a method to record all the EventTrigger into a EventTriggersContainer

Link copied to clipboard

An fun interface that a mountable view can extend which informs that this mountable content has other LithoView children. This is used to make sure to unmount this view's children when unmounting this view itself.

Link copied to clipboard
fun interface HookInitializer<T>

Interface for a block of code that will initialize a hook value.

Link copied to clipboard

EXPERIMENTAL - fun interface for a block of code that will update state created with useState. See KState.kt for more details.

Link copied to clipboard
open class HostMountContentPool : MountItemsPool.ItemPool
A specific MountContentPool for HostComponent - needed to do correct recycling with things like duplicateParentState.
Link copied to clipboard
interface ImageContent

A UI element that contains simple resource drawables.

Link copied to clipboard
@ThreadSafe
class InitialStateContainer

The InitialStateContainer is a lookaside table used by a ComponentTree to create initial states for Components. The idea is that the onCreateInitialState result for each component will be cached and stored here so that we can guarantee it's not called multiple times on multiple threads. We keep the initial states cached as long as there is a layout happening for the ComponentTree. As soon as we detect that all in-flights layout have terminated we can clean up the initial states cache.

Link copied to clipboard
Components should implement an event of this type in order to intercept Android touch events.
Link copied to clipboard

Container for inter-stage props. A component with inter-stage props will generate its own InterStagePropsContainer implementation which will hold fields for each inter-stage prop specified.

Link copied to clipboard
class JavaStyle
Link copied to clipboard
abstract class KComponent : Component

Base class for Kotlin Components.

Link copied to clipboard

The StateContainer implementation for Kotlin components. It tracks all the state defined by useState calls for the same component. See KState for how this is being used. This is a purely immutable class and it exposes utilities to create a new instance with either a new piece of state or by changing the value at a given index

Link copied to clipboard
annotation class LayerType

Enumerates all the valid valid for Component.Builder#layerType(int, Paint)

Link copied to clipboard
interface LayoutProps
Link copied to clipboard
The main role of LayoutState is to hold the output of layout calculation.
Link copied to clipboard
open class LayoutThreadPoolConfigurationImpl @JvmOverloads constructor(val corePoolSize: Int, val maxPoolSize: Int, val threadPriority: Int = ComponentsConfiguration.DEFAULT_BACKGROUND_THREAD_PRIORITY, val layoutThreadInitializer: Runnable? = null) : LayoutThreadPoolConfiguration

Configures a thread pool used for layout calculations.

Link copied to clipboard
class LayoutThreadPoolExecutor @JvmOverloads constructor(corePoolSize: Int, maxPoolSize: Int, priority: Int, layoutThreadInitializer: Runnable? = null) : ThreadPoolExecutor

Thread pool executor implementation used to calculate layout on multiple background threads.

Link copied to clipboard
class LayoutTreeFuture(resolveResult: ResolveResult, currentLayoutState: LayoutState?, diffTreeRoot: DiffNode?, perfEvent: PerfEvent?, widthSpec: Int, heightSpec: Int, treeId: Int, version: Int, source: Int) : TreeFuture<LayoutState>
Link copied to clipboard
class LithoAnimtableItem(id: Long, absoluteBounds: Rect, outputType: Int, nodeInfo: NodeInfo?, transitionId: TransitionId?) : AnimatableItem

Litho's implementation of the AnimatableItem required by the TransitionsExtension to power animations. This object should NOT be used to inform the should update during mounting, therefore it should NOT be used to host any such information.

Link copied to clipboard
data class LithoConfiguration(val componentsConfig: ComponentsConfiguration, val areTransitionsEnabled: Boolean, val renderUnitIdGenerator: RenderUnitIdGenerator?, val visibilityBoundsTransformer: VisibilityBoundsTransformer?)
Link copied to clipboard

Simple wrapper of GestureDetector to be used in Litho lifecycle methods. Using this class ensures that UI Thread Handler is used for detecting gestures.

Link copied to clipboard
Helper for dispatching events to multiple MountListenerExtensions in Litho.
Link copied to clipboard
class LithoLayoutContext(val treeId: Int, val cache: MeasuredResultCache, rootContext: ComponentContext?, treeState: TreeState?, val layoutVersion: Int, val rootComponentId: Int, val isAccessibilityEnabled: Boolean, val layoutCache: LayoutCache, currentDiffTree: DiffNode?, layoutStateFuture: TreeFuture<*>?) : CalculationContext

Wraps objects which should only be available for the duration of a LayoutState, to access them in other classes such as ComponentContext during layout state calculation. When the layout calculation finishes, the LayoutState reference is nullified. Using a wrapper instead of passing the instances directly helps with clearing out the reference from all objects that hold on to it, without having to keep track of all these objects to clear out the references.

Link copied to clipboard
class LithoLayoutContextExtraData(yogaNode: YogaNode) : LayoutContextExtraData<LithoLayoutContextExtraData.LithoLayoutExtraData?>
Link copied to clipboard
class LithoLayoutData(val width: Int, val height: Int, val currentLayoutStateId: Int, val previousLayoutStateId: Int, val expandedTouchBounds: Rect?, val layoutData: Any?, val isSizeDependant: Boolean, val debugHierarchy: DebugHierarchy.Node?) : Equivalence<LithoLayoutData>

This object will host the data associated with the component which is generated during the measure pass, for example: the InterStagePropsContainer, and the UpdateState. It will be created in LayoutResult#calculateLayout(LayoutContext, int, int). This object will be returned by LayoutResult#getLayoutData(), then written to the layout data in RenderTreeNode during reduce.

Link copied to clipboard

A data structure that holds the result of Litho layout phase.

Link copied to clipboard
open class LithoLayoutResult(val context: ComponentContext, val node: LithoNode, val layoutOutput: YogaLayoutOutput) : LayoutResult

This is the default implementation of a LayoutResult for Litho.

Link copied to clipboard

Can observe lifecycle changes that a LithoVisibilityEventsController goes through.

Link copied to clipboard

Exception class used to add additional Litho metadata to a crash.

Link copied to clipboard
class LithoMountData(content: Any?)

This class hosts any extra mount data related to MountItem.

Link copied to clipboard

LithoNode is the Node implementation of Litho.

Link copied to clipboard
Link copied to clipboard
class LithoPrimitive(val primitive: Primitive, val style: Style?)

A class that represents a Primitive with Style that should be applied to the PrimitiveComponent.

Link copied to clipboard

An implementation of BaseMountingView that can mount a LayoutState without the need for a ComponentTree

Link copied to clipboard
abstract class LithoRenderUnit : RenderUnit<Any> , TransitionRenderUnit
Link copied to clipboard
abstract class LithoStartupLogger

Logger for tracking Litho events happening during startup.

Link copied to clipboard
fun interface LithoTooltip
Link copied to clipboard
Link copied to clipboard
class LithoTree(val stateUpdater: StateUpdater, val mountedViewReference: MountedViewReference, val errorComponentReceiver: ErrorComponentReceiver, val lithoTreeLifecycleProvider: LithoTreeLifecycleProvider, val id: Int)

Represents a pointer to the Tree that a ComponentContext is attached to

Link copied to clipboard
Link copied to clipboard
A ViewGroup that can host the mounted state of a Component.
Link copied to clipboard

Helper class to access metadata from LithoView that is relevant during end to end tests. In order for the data to be collected, ComponentsConfiguration#isEndToEndTestRun must be enabled.

Link copied to clipboard

Manages a Litho ComponentTree lifecycle and informs subscribed LithoLifecycleListeners when a lifecycle state occurs.

Link copied to clipboard

Default LithoVisibilityEventsController implementation. Defines the standard state changes for a Litho ComponentTree. A custom LithoVisibilityEventsController implementation can change the lifecycle state but delegate to this to handle the effects of the state change. See an example of how this facilitates a custom lifecycle implementation in AOSPLithoVisibilityEventsController.

Link copied to clipboard
class LithoYogaBaselineFunction : YogaBaselineFunction
Link copied to clipboard
class LithoYogaMeasureFunction : YogaMeasureFunction
Link copied to clipboard

This class provides utilities for extracting information through ComponentsLogger#getExtraAnnotations(TreeProps) and transforming them so they can be logged.

Link copied to clipboard
open class LongClickEvent
Components should implement an event of this type in order to receive Android long click events.
Link copied to clipboard
class MatrixDrawable<T : Drawable?> : Drawable, Drawable.Callback, Touchable, TransitionUtils.BoundsCallback

A Drawable that wraps another drawable.

Link copied to clipboard

An utility class to verify that an old measured size is still compatible to be used with a new measureSpec.

Link copied to clipboard
class MeasuredResultCache @JvmOverloads constructor(delegateCache: MeasuredResultCache? = null)

Read & write layout result cache used during render phase for caching measured results that happen during component-measure. This cache can be accessed via components or litho-nodes.

Link copied to clipboard

An interfaced used by ComponentContext to access the root view on which a hierarchy is mounted. This interface needs to be passed in the ComponentContext when it's built.

Link copied to clipboard
Link copied to clipboard
class MountSpecLithoRenderUnit : LithoRenderUnit, ContentAllocator<Any>

This RenderUnit encapsulates a Litho output to be mounted using Render Core.

Link copied to clipboard
data class NestedLithoResolveContext(val treeId: NestedTreeId, val androidContext: Context, val config: LithoConfiguration, val currentResolveResult: ResolveResult?, val stateUpdateRequest: StateUpdateRequester, val stateCommitListener: StateCommitListener? = null, val errorComponent: (Component?) -> Unit = { /* TODO: provide default implementation */}, val rootHostReference: NestedMountedViewReference = NestedMountedViewReference(), val lifecycleProvider: NestedLithoTreeLifecycleProvider = NestedLithoTreeLifecycleProvider(), val usePreviousLayoutState: Boolean)
Link copied to clipboard

The NestedLithoTree should be used to render Litho components in a container, say a Primitive like a ScrollView or when embedded Litho hierarchies in other RC framework hierarchies.

Link copied to clipboard
data class NestedLithoTreeState(val id: Int = LithoTree.generateComponentTreeId(), var currentState: TreeState?, var currentResolveResult: ResolveResult? = null, var currentLayoutState: LayoutState? = null, val pendingStateUpdates: MutableList<PendingStateUpdate> = ArrayList())
Link copied to clipboard
open class NestedLithoViewsExtension : MountExtension<Input, State> , OnItemCallbacks<State>
MountExtension to ensure that content with nested LithoViews is properly clearing those LithoViews when the item is unmounted.
Link copied to clipboard
Link copied to clipboard
class NestedTreeHolder @JvmOverloads constructor(propContainer: TreePropContainer? = null, val cachedNode: LithoNode? = null, var parentContext: ComponentContext? = null) : LithoNode

This class is a placeholder for the unresolved layout and result of a Components which implement the com.facebook.litho.annotations.OnCreateLayoutWithSizeSpec.The TreePropContainer, padding and border width properties and held separately so that they can be copied into the actual nested tree layout before measuring it.

Link copied to clipboard

This is an output only NestedTreeHolderResult; this is created by a NestedTreeHolder.

Link copied to clipboard
class NestedTreeId(val id: Int)
Link copied to clipboard
class NestedTreeYogaLayoutProps(val node: YogaNode) : YogaLayoutProps
Link copied to clipboard
object NodeConfig

A helper class that defines a configurable sizes for Pooling.

Link copied to clipboard
class NodeInfo : Equivalence<NodeInfo>

NodeInfo holds information that are set to the LithoNode and needs to be used while mounting.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

This LithoNode represents a component that renders to null. This is required to support reconciliation of state, and transitions on a component that conditionally renders to null.

Link copied to clipboard
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to onInitializeAccessibilityEvent
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to onInitializeAccessibilityNodeInfo
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to onPopulateAccessibilityEvent
Link copied to clipboard
Components should implement an event of this type in order to be notified so that they can implement their own accessibility support.
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to onRequestSendAccessibilityEvent
Link copied to clipboard
open class Output<T>

Type for parameters that are logical outputs.

Link copied to clipboard
data class PendingStateUpdate(val key: String, val updater: StateUpdateApplier, val isLayoutState: Boolean, val isAsync: Boolean, val isLazy: Boolean = false, val attribution: String? = null)
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to performAccessibilityAction
Link copied to clipboard
class PerformActionForVirtualViewEvent(host: View, nodeInfo: AccessibilityNodeInfoCompat, virtualViewId: Int, action: Int, arguments: Bundle?)
Link copied to clipboard

Interface defining a result calculated from a TreeFuture that could be interrupted, and therefore be partial (and resumed on the UI thread).

Link copied to clipboard
abstract class PrimitiveComponent : Component

Base class for Kotlin primitive components. This class encapsulates some of the Mount Spec APIs. All Kotlin primitive components must extend this class.

Link copied to clipboard
Link copied to clipboard
class Ref<T>(value: T)

A simple mutable holder of a value.

Link copied to clipboard
An Event that is triggered when a component is render complete.
Link copied to clipboard
class RenderResult @JvmOverloads constructor(val component: Component?, val transitions: List<Transition>? = null, val useEffectEntries: List<Attachable>? = null)

The result of a Component#render call. This will be the Component this component rendered to, potentially as well as other non-Component metadata that resulted from that call, such as transitions that should be applied.

Link copied to clipboard
annotation class RenderSource
Link copied to clipboard
Link copied to clipboard

Keeps track of the last mounted @Prop/@State a component was rendered with for components that care about them (currently, this is just for ComponentSpecs that use Diff's of props in any of their lifecycle methods).

Link copied to clipboard
class RenderUnitIdGenerator(val componentTreeId: Int)

Class that handles generation of unique IDs for RenderUnits for a given ComponentTree. The ID generation uses the component key to create an ID, and creates unique IDs for any components under the same ComponentTree.

Link copied to clipboard
class ResolveContext(val treeId: Int, val cache: MeasuredResultCache, treeState: TreeState?, val layoutVersion: Int, val rootComponentId: Int, val isAccessibilityEnabled: Boolean, treeFuture: TreeFuture<*>?, val currentRoot: LithoNode?, val perfEventLogger: PerfEvent?, val componentsLogger: ComponentsLogger?) : CalculationContext
Link copied to clipboard
object Resolver
Link copied to clipboard
data class ResolveResult(val node: LithoNode?, val context: ComponentContext, val component: Component, cache: MeasuredResultCache, val treeState: TreeState, val isPartialResult: Boolean, val version: Int, val eventHandlers: List<Pair<String, EventHandler<*>>>?, val outputs: Resolver.Outputs?, val contextForResuming: ResolveContext?) : PotentiallyPartialResult
Link copied to clipboard
Link copied to clipboard
interface ResourcesScope : BaseResourcesScope

The receiver for KComponent methods which need to access resources and widgets like Row, Column, and Text. This class exposes the ability to access functions defined in Resources like stringRes/drawableRes etc.

Link copied to clipboard
Link copied to clipboard

Takes a component and returns a new component that it is wrapped in. Used to create a common root wrapper in ComponentTree.

Link copied to clipboard

A Component that renders its children in a row.

Link copied to clipboard
class ScopedComponentInfo(val component: Component, val context: ComponentContext, errorEventHandler: EventHandler<ErrorEvent>?) : Cloneable
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to sendAccessibilityEvent
Link copied to clipboard
Components should implement an event of this type in order to receive callbacks to sendAccessibilityEventUnchecked

LithoVisibilityEventsController implementation that can be used to subscribe a nested ComponentTree to listen to state changes of the lifecycle provider that the parent ComponentTree is also subscribed to.

Link copied to clipboard
class Size

Public API for MeasureOutput.

Link copied to clipboard
object SizeSpec

A SizeSpec encapsulates the layout requirements passed from parent to child. Each SizeSpec represents a requirement for either the width or the height. A SizeSpec is comprised of a size and a mode. There are two possible modes:

Link copied to clipboard
Base class for all component generated via the Spec API (@LayoutSpec and @MountSpec).
Link copied to clipboard
class SpecGeneratedComponentLayout(layoutOutput: LithoLayoutOutput, paddingSet: Boolean, backgroundDrawable: Drawable?) : ComponentLayout
Link copied to clipboard
class State<T>

Interface with which a component gets the value from a state or updates it.

Link copied to clipboard
fun interface StateCommitListener
Link copied to clipboard
abstract class StateContainer : Cloneable

Implemented by the class used to store state within both Components and Sections to store state.

Link copied to clipboard

Holds information about the current State of the components in a Component Tree.

Link copied to clipboard
Link copied to clipboard
interface StateUpdater

StateUpdater lets a Component rendered with a scoped ComponentContext interact with Litho's state. An implementation of StateUpdater is responsible for collecting state update operations and schedule a new Resolve/Layout step to occur. The default implementation of StateUpdater is ComponentTree, but it might be useful to implement this interface when integrating Litho in different rendering frameworks where it's not desirable for Litho to control the resolve/layout/commit process.

Link copied to clipboard
fun interface StateUpdateRequester
Link copied to clipboard
class StateValue<T> : Output<T>

Used to represent the value of a Component's State. Must be used to pass State as parameter in methods annotated with @OnUpdateState.

Link copied to clipboard
open class Style(previousStyle: Style?, item: StyleItem<*>?)

An immutable ordered collection of attributes ( StyleItem s) that can be applied to a component, like width or click handling.

Link copied to clipboard

Backwards compatibility to allow Java code to define Styles used by Kotlin components

Link copied to clipboard
interface StyleItem<T>

Part of a Style that can apply an attribute to an underlying Component, e.g. width or click handling.

Link copied to clipboard
interface StyleItemField
Link copied to clipboard
A Component that wraps another component for testing purposes.
Link copied to clipboard
class TestItem

Holds information about a TestOutput.

Link copied to clipboard
open class TestLayoutState
This should be only used with the deprecated DiffNode based testing infrastructure.
Link copied to clipboard
@VisibleForTesting(otherwise = 3)
class TestOutput

Stores information about a Component which is only available when tests are run. TestOutputs are calculated in LayoutState and transformed into TestItems while mounting.

Link copied to clipboard
interface TextContent

An UI Element that contains textual content. This element can have more than one textual content. For example, one Mountable wrapping a complex custom view can have multiple text views, and therefore, multiple TextContent.Item

Link copied to clipboard
class ThreadPoolLayoutHandler : RunnableHandler

LithoHandler implementation that uses a thread pool to calculate the layout.

Link copied to clipboard

ThreadTracingRunnable tries to help debugging crashes happening across threads showing the stacktrace of the crash origin which scheduled this runnable.

Link copied to clipboard

Thread assertion utilities.

Link copied to clipboard

Specify a position to anchor a DeprecatedLithoTooltip on a component.

Link copied to clipboard
interface Touchable

Any interface for mounted items that need to capture motion events from its ComponentHost.

Link copied to clipboard
open class TouchEvent
Components should implement an event of this type in order to receive Android touch events.
Link copied to clipboard

Compound touch delegate that forward touch events to recyclable inner touch delegates.

Link copied to clipboard
Base class that wraps a FutureTask to allow calculating the same result across threads.
Link copied to clipboard
interface TreeProp<T>
Link copied to clipboard

A data structure to store tree props.

Link copied to clipboard
class TreePropProviderImpl(classProps: Array<out ClassValuePair<*>>? = null, treeProps: Array<out TreePropValuePair<*>>? = null, child: Component) : KComponent
Link copied to clipboard

Defines a single tree prop override. Unlike ClassValuePair there can be multiple TreePropValuePair with the same corresponding class.

Link copied to clipboard
class TreeState
Link copied to clipboard
fun interface UnbindDynamicFunc

Interface for the onUnbindDynamic function: use onUnbindDynamic to define the cleanup function for your dynamic values.

Link copied to clipboard
Link copied to clipboard
typealias ViewBinder = RenderUnit.Binder<Any?, View, Any?>
Link copied to clipboard
A component that can wrap a view using a ViewBinder class to bind the view and a to create the mount contents.
Link copied to clipboard
class VirtualViewKeyboardFocusChangedEvent(host: View, nodeInfo: AccessibilityNodeInfoCompat?, virtualViewId: Int, hasFocus: Boolean, superDelegate: AccessibilityDelegateCompat)

Components should implement an event of this type in order to be notified when keyboard focus changes on any virtual views implemented.

Link copied to clipboard
interface WorkingRange
Link copied to clipboard

A container that stores working range related information. It provides two major methods: a register method to store a working range with a component, and a dispatch method that dispatches event to components to trigger their delegated methods.

Link copied to clipboard

A handler that stores the range status of components with given working range.

Link copied to clipboard
Utility class for wrapping an existing Component.
Link copied to clipboard
typealias YogaEdgeFloatFunction = (YogaEdge, Float) -> Unit
Link copied to clipboard
typealias YogaEdgeIntFunction = (YogaEdge, Int) -> Unit
Link copied to clipboard
data class YogaLayoutOutput(val yogaNode: YogaNode, val widthFromStyle: Float = YogaConstants.UNDEFINED, val heightFromStyle: Float = YogaConstants.UNDEFINED, _widthSpec: Int = UNSPECIFIED, _heightSpec: Int = UNSPECIFIED, _lastMeasuredSize: Long = Long.MIN_VALUE, _isCachedLayout: Boolean = false, _isDiffedLayout: Boolean = false, _layoutData: Any? = null, _wasMeasured: Boolean = false, _cachedMeasuresValid: Boolean = false, _measureHadExceptions: Boolean = false, _contentRenderUnit: LithoRenderUnit? = null, _hostRenderUnit: LithoRenderUnit? = null, _backgroundRenderUnit: LithoRenderUnit? = null, _foregroundRenderUnit: LithoRenderUnit? = null, _borderRenderUnit: LithoRenderUnit? = null, _diffNode: DiffNode? = null, _delegate: LayoutResult? = null, _nestedResult: LithoLayoutResult? = null, _adjustedBounds: Rect = Rect()) : LithoLayoutOutput

A wrapper around YogaNode that implements LithoLayoutOutput, which will be used internally by LithoYogaLayoutFunction.

Link copied to clipboard
open class YogaLayoutProps(val node: YogaNode) : LayoutProps

Properties

Link copied to clipboard

Hosts API to debug state

Functions

Link copied to clipboard
inline fun <A, B, R> allNotNull(var1: A?, var2: B?, block: (A, B) -> R): R?

Util method that returns the result of block if both var1 and var2 are not null. Otherwise returns null.

inline fun <A, B, C, R> allNotNull(var1: A?, var2: B?, var3: C?, block: (A, B, C) -> R): R?

Util method that returns the result of block if all three var1, var2 and var3 are not null. Otherwise returns null.

Link copied to clipboard
fun <ContentType : ViewGroup> MountConfigurationScope<ContentType>.bindToRenderTreeView(state: NestedLithoTreeState, getRenderTreeView: ContentType.() -> LithoRenderTreeView)
Link copied to clipboard
inline fun ResourcesScope.Column(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null): Column

Constructs a new Column without any children.

inline fun ResourcesScope.Column(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null, init: FlexboxContainerScope.() -> Unit): Column

Constructs a new Column. Add children by using FlexboxContainerScope.child or FlexboxContainerScope.children:

Link copied to clipboard
fun <E : Any, R> create(onEvent: (E) -> R): EventHandler<E>
fun <E : Any, R> create(id: Int, params: Array<Any?>?, onEvent: (E) -> R): EventHandler<E>
fun create(unit: LithoRenderUnit, bounds: Rect, layoutData: LithoLayoutData? = null, parent: RenderTreeNode? = null): RenderTreeNode
Link copied to clipboard
fun ResourcesScope.createColumn(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null, resolvedContainerScope: FlexboxContainerScope?): Column

Internal function to allow Column to be inlineable.

Link copied to clipboard
fun createdNestedTreeComponentContext(treeId: Int, androidContext: Context, treeProps: TreePropContainer?, lithoConfiguration: LithoConfiguration, updatedState: TreeState, updater: StateUpdateRequester, rootHostReference: NestedMountedViewReference, errorComponent: (Component?) -> Unit, lifecycleProvider: NestedLithoTreeLifecycleProvider): ComponentContext
Link copied to clipboard
fun ResourcesScope.createRow(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null, resolvedContainerScope: FlexboxContainerScope?): Row

Internal function to allow Row to be inlineable.

Link copied to clipboard
inline fun ComponentContext.dimenRes(@DimenRes id: Int): Dimen

Resolve a dimen resource ID as a Dimen value.

Link copied to clipboard
fun BaseResourcesScope.drawableColor(@ColorInt color: Int): Drawable
fun BaseResourcesScope.drawableColor(@ColorInt color: Long): Drawable

Return a android.graphics.drawable.Drawable for a ColorInt value as a Drawable instance.

Link copied to clipboard
inline fun <E : Any> eventHandler(noinline onEvent: (E) -> Unit): EventHandler<E>
inline fun <E : Any> eventHandler(noinline onEvent: (E) -> Unit, tag: String?): EventHandler<E>
Link copied to clipboard
inline fun <E : Any, R> eventHandlerWithReturn(noinline onEvent: (E) -> R): EventHandler<E>
Link copied to clipboard
inline fun <T> T?.getOrCreate(initBlock: () -> T): T

Util method that returns the instance if it's not null otherwise calls initBlock to create a new instance.

Link copied to clipboard
inline fun <T : Any> ComponentScope.getTreeProp(): T?

Returns the instance registered for the type T in this hierarchy, and null if no value was registered. Tree props are registered for a sub-hierarchy via TreePropProvider or com.facebook.litho.annotations.OnCreateTreeProp in the Spec API.

Link copied to clipboard
inline fun handle(handle: Handle, componentLambda: () -> Component): Component

Sets a handle on the given Component returned in the lambda, e.g.

Link copied to clipboard
fun hash(vararg values: Any?): Int

Polyfill of Objects.hash that can be used on API<19.

Link copied to clipboard
inline fun key(key: String, componentLambda: () -> Component): Component

Sets a manual key on the given Component returned in the lambda, e.g.

Link copied to clipboard

Backwards compatibility for a Kotlin Component to accept a Style and apply it to a Java Spec Component. Using this builder method is the equivalent of setting all common props the Style defines.

Link copied to clipboard
fun <T : Any> legacyTreePropOf(clazz: Class<T>): TreeProp<T?>
Link copied to clipboard
fun <T> mergeLists(a: List<T>?, b: List<T>?): List<T>?
Link copied to clipboard
fun NestedLithoPrimitive(renderUnitId: Long, resolveContext: NestedLithoResolveContext, component: Component, treeProps: TreePropContainer?, updatedState: TreeState): Pair<Primitive, ResolveResult>

Returns a Primitive, and the ResolveResult that renders an embedded Litho component. This API should only be used when embedding Litho in a non Litho RC framework, like Bloks. This API accepts the updated state; this API should only be used if the client framework applies state updates before resolving the component to a Primitive.

fun NestedLithoPrimitive(renderUnitId: Long, resolveContext: NestedLithoResolveContext, component: Component, treeProps: TreePropContainer?, currentState: TreeState, updates: List<PendingStateUpdate>?): Pair<Primitive, ResolveResult>

Returns a Primitive, and the ResolveResult that renders an embedded Litho component. This API should only be used when embedding Litho in a non Litho RC framework, like Bloks. This API accepts the current state and pending state updates.

Link copied to clipboard
inline fun NullableTreePropProvider(vararg props: ClassValuePair<*>, component: () -> Component?): TreePropProviderImpl?

Same as TreePropProvider, but accepts a lambda that may return a nullable component, in which case it'll return null itself.

Link copied to clipboard
inline fun onCleanup(crossinline cleanupFunc: () -> Unit): CleanupFunc

Defines a cleanup function to be invoked when the owning Component is detached or the deps in useEffect change.

Link copied to clipboard
fun preloadLithoClasses(additionalClasses: () -> Set<Class<*>>? = null)

Utility for preloading classes that should be loaded early but may not be accessible outside of Litho.

Link copied to clipboard
Link copied to clipboard

Returns the instance registered for the type T in this hierarchy, throws if no value was registered. Tree props are registered for a sub-hierarchy via TreePropProvider or com.facebook.litho.annotations.OnCreateTreeProp in the Spec API.

Link copied to clipboard
inline fun ResourcesScope.Row(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null): Row

Constructs a new Column without any children.

inline fun ResourcesScope.Row(alignContent: YogaAlign? = null, alignItems: YogaAlign? = null, justifyContent: YogaJustify? = null, wrap: YogaWrap? = null, isReversed: Boolean = false, style: Style? = null, init: FlexboxContainerScope.() -> Unit): Row

Constructs a new Row. Add children by using FlexboxContainerScope.child or FlexboxContainerScope.children:

Link copied to clipboard
fun Activity.setContent(component: Component)
Link copied to clipboard
fun setViewForeground(view: View, foreground: Drawable?)
fun setViewForeground(view: View, foregroundColor: Int)
Link copied to clipboard
fun YogaDirection.toLayoutDirection(): LayoutDirection
Link copied to clipboard
fun LayoutDirection.toYogaDirection(): YogaDirection
Link copied to clipboard
fun <T> treePropOf(defaultValueProducer: () -> T): TreeProp<T>
Link copied to clipboard
inline fun TreePropProvider(vararg props: TreePropValuePair<*>, component: () -> Component): Component

A component which provides one or more TreeProp values to the given child hierarchy. A tree prop is a mapping from a TreeProp key object to an value of a corresponding type which is accessible throughout the entire subtree where it's defined.

inline fun TreePropProvider(vararg props: ClassValuePair<*>, component: () -> Component): TreePropProviderImpl

A component which provides one or more tree props to the given child hierarchy. A tree prop is a mapping from a type to an instance of that type which is accessible throughout the entire subtree where it's defined.

Link copied to clipboard
fun <T> ComponentScope.useCached(vararg inputs: Any?, calculator: () -> T): T

Create a CachedValue variable within a Component. The calculator will provide the calculated value if it hasn't already been calculated or if the inputs have changed since the previous calculation.

Link copied to clipboard
fun <R> ComponentScope.useCallback(callback: () -> R): () -> R

useCallback allows a parent to pass a child component a callback which: 1) maintains referential equality across multiple layout passes 2) is updated to have the latest parent props and state, even if the child doesn't re-render.

fun <A, R> ComponentScope.useCallback(callback: (A) -> R): (A) -> R

1-parameter overload of useCallback: refer to docs there.

fun <A, B, R> ComponentScope.useCallback(callback: (A, B) -> R): (A, B) -> R

2-parameter overload of useCallback: refer to docs there.

fun <A, B, C, R> ComponentScope.useCallback(callback: (A, B, C) -> R): (A, B, C) -> R

3-parameter overload of useCallback: refer to docs there.

fun <A, B, C, D, R> ComponentScope.useCallback(callback: (A, B, C, D) -> R): (A, B, C, D) -> R

4-parameter overload of useCallback: refer to docs there.

fun <A, B, C, D, E, R> ComponentScope.useCallback(callback: (A, B, C, D, E) -> R): (A, B, C, D, E) -> R

5-parameter overload of useCallback: refer to docs there.

fun <A, B, C, D, E, F, R> ComponentScope.useCallback(callback: (A, B, C, D, E, F) -> R): (A, B, C, D, E, F) -> R

6-parameter overload of useCallback: refer to docs there.

fun <A, B, C, D, E, F, G, R> ComponentScope.useCallback(callback: (A, B, C, D, E, F, G) -> R): (A, B, C, D, E, F, G) -> R

7-parameter overload of useCallback: refer to docs there.

Link copied to clipboard
fun ComponentScope.useEffect(onAttach: () -> CleanupFunc?)
fun ComponentScope.useEffect(vararg deps: Any?, onAttach: () -> CleanupFunc?)

Registers a callback to perform side-effects when this Component is attached/detached from the tree.

Link copied to clipboard
fun ComponentScope.useErrorBoundary(onError: (exception: Exception) -> Unit)

Registers a callback to perform error handling for exceptions that might happen in child components down in the tree.

Link copied to clipboard
fun PrimitiveComponentScope.useNestedTree(androidContext: Context = context.androidContext, config: ComponentsConfiguration = context.lithoConfiguration.componentsConfig, root: Component, treeProps: TreePropContainer? = context.treePropContainer): Pair<NestedLithoTreeState, ResolveResult>
Link copied to clipboard
fun <T> ComponentScope.useRef(initializer: () -> T): Ref<T>

Declares a mutable, main-thread confined reference that will be persisted across renders with an initial value provided by the initializer. It's similar to useState, except that the returned reference is mutable and updating it will not cause a re-render.

Link copied to clipboard
fun <T> ComponentScope.useState(initializer: () -> T): State<T>

Declares a state variable within a Component. The initializer will provide the initial value if it hasn't already been initialized in a previous render of the Component.

Link copied to clipboard
inline fun ResourcesScope.Wrapper(style: Style, content: ResourcesScope.() -> Component): Wrapper

Builder function for creating Wrapper components. It's useful for adding additional Style props to a given component.