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
open class AOSPLithoVisibilityEventsController @JvmOverloads constructor(val lifecycleOwner: LifecycleOwner, allowOffMainThreadRegistration: Boolean = false) : LithoVisibilityEventsController, LifecycleEventObserver, AOSPLifecycleOwnerProvider

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
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 @JvmOverloads constructor(context: ComponentContext, attrs: AttributeSet? = null) : ComponentHost, RenderCoreExtensionHost, AnimatedRootHost, UiStateReadRecords.Config
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

Contains the data and flags for view attributes that have been migrated to the onBindViewWithDescription binder pattern behind the useViewStyleBinders config flag.

Link copied to clipboard

Contains the 23 view attribute properties from NodeInfo that have been migrated to the onBindViewWithDescription binder pattern behind the useViewStyleBinders config flag.

Link copied to clipboard

Contains the 21 view attribute properties that have been migrated to the onBindViewWithDescription binder pattern behind the useViewStyleBinders config flag.

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
class CachedValue(val hookKey: HookKey?, val deps: Array<*>, val value: Any?)

A single hook's cached value.

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

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. The method is equivalent to the Android method View.OnClickListener.onClick. An example of the correct usage is:

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
typealias ColumnBuilder = Column

Migration scaffolding: a typealias for the legacy SpecGen Column class under a non-colliding name. See RowBuilder for rationale.

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. Contains extra bookkeeping information used internally in the library.

Link copied to clipboard

Focus change listener that triggers its underlying event handler.

Link copied to clipboard
open class ComponentHost(context: Context, attrs: AttributeSet?, unsafeModificationPolicy: ComponentHost.UnsafeModificationPolicy?) : Host, DisappearingHost, SupportsPivotTransform

A ViewGroup that can host the mounted state of a Component. This is used by MountState to wrap mounted drawables to handle click events and update drawable states accordingly.

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

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. 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.

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

Thread-safe singleton registry that holds weak references to all ComponentTree instances that are still in memory, including released ones that have not been garbage collected yet.

Link copied to clipboard
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, nodeSupplier: () -> List<RenderTreeNode>, preAllocator: (Context, ContentAllocator<*>, PoolScope) -> 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
class DefaultGlobalKey(val key: Int, val position: Int, val parent: GlobalKey?) : GlobalKey

Memory-efficient linked structure for auto-generated keys. Used when the config flag is on and no manual key is present in the ancestry.

Link copied to clipboard

This is an output only DeferredLithoLayoutResult; this is created by a DeferredLithoNode.

Link copied to clipboard
class DeferredLithoNode @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 and com.facebook.litho.layout.RenderWithConstraints.The TreePropContainer, padding and border width properties and held separately so that they can be copied into the actual deferred node result before measuring it.

Link copied to clipboard
class DeferredNodeYogaLayoutProps(val node: YogaNode) : YogaLayoutProps
Link copied to clipboard
class DelegatingEventHandler<E : Any> @VisibleForTesting(otherwise = 4) constructor(eventHandler1: EventHandler<E>, eventHandler2: EventHandler<E>) : EventHandler<E>

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. The framework takes care of finding the position where the tooltip needs to anchored.

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 View.dispatchPopulateAccessibilityEvent

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
Link copied to clipboard

Takes care of dynamic Props

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<Any?>>)
Link copied to clipboard
class Edges : Equivalence<Edges?>
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
class EquivalentEventLambda<E, R>(eventHandler: EventHandler<E>, returnsUnit: Boolean) : Function1<E, R>

A Function1 event lambda that is backed by a real EventHandler, so that lambda-shaped event handlers behave exactly like the ones produced by the generated non-lambda on<Event>(c) factory.

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

An event used internally to propagate exceptions up the hierarchy. Don't use this directly. Use com.facebook.litho.annotations.OnError instead.

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>(val id: Int, val mode: EventHandlerRebindMode, var dispatchInfo: EventDispatchInfo, val params: Array<out Any?>?) : Function<Void?> , Equivalence<EventHandler<*>?>
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: Any, 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
data class EventTriggerKey(val parentKey: Any, val id: Int, val childKey: String)

Composite key for EventTrigger lookup. Uses the parent's key (a GlobalKey for components, a String for sections), the trigger method ID, and the child key to form a unique identity.

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

Base for the LEGACY Row.Builder / Column.Builder. It keeps the exact Component.ContainerBuilder fluent surface (so every existing Row.create(c)...build() call site — Java or Kotlin — compiles unchanged and so Component.ContainerBuilder<?> handles keep working). The selected implementation is snapshotted when the builder is created: setters write directly to the legacy component when the flag is off, and accumulate a Style only when the flag is on.

Link copied to clipboard

Event triggered when focus changes on a Component.

Link copied to clipboard
class FocusOrderModel(val key: String)
Link copied to clipboard

Create multiple FocusOrderModels, which can to be used to specify a focus traversal order.

Link copied to clipboard
sealed class GlobalKey

A sealed class hierarchy representing a component's global key in the Litho component tree.

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
data class HookGlobalKey(val globalKey: GlobalKey, val hookKey: Any, val scope: RenderScope)

A globally unique key for a hook call within a component tree. Combines the component's global key with the hook-local identity and the RenderScope in which the hook executes.

Link copied to clipboard

Executes the hook-identity code path once at startup so that Meta's production ART profile learns it.

Link copied to clipboard
fun interface HookInitializer<T>

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

Link copied to clipboard
open class HookKey

A structured key that identifies a hook call site within a component's render method.

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
class HostMountContentPool(maxSize: Int, isEnabled: Boolean) : MountContentPools.ContentPool

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 InitialState

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

An AutoCloseable scope that pairs TreeState register/unregister lifecycle into a single object. Creating a scope registers the TreeState's InitialState handler; closing it unregisters. Close is idempotent—safe to call multiple times.

Link copied to clipboard

Components should implement an event of this type in order to intercept Android touch events. The method is equivalent to the Android method ViewGroup.onInterceptTouchEvent - implementations should return true if they intercepted the event and wish to receive subsequent events, and false An example of the correct usage is:

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 @JvmOverloads constructor(style: Style = Style)
Link copied to clipboard
abstract class KComponent : Component

Base class for Kotlin Components.

Link copied to clipboard

The StateContainer implementation for Kotlin components. Tracks all state defined by useState calls for the same component (see KState for usage). Immutable by default: every copy-on-write mutation returns a new instance with the prior entries copied and one entry added or replaced. The one exception is the transient render-owned fork (mutableForkWith / mutateInPlace): a render forks a single mutable copy of its component's container and then mutates that copy in place for the rest of the pass, tracked by ComponentScope.ownedStateContainer. Committed/shared containers are never mutated in place - a subsequent render forks them.

Link copied to clipboard
annotation class LayerType

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

Link copied to clipboard

Guards View.LAYER_TYPE_HARDWARE promotions against the device's GPU max texture size.

Link copied to clipboard

A container component that owns the children it is given.

Link copied to clipboard

LayoutParams that override the LayoutManager.

Link copied to clipboard
interface LayoutProps
Link copied to clipboard
class LayoutState : IncrementalMountExtensionInput, VisibilityExtensionInput, TransitionsExtensionInput, EndToEndTestingExtension.EndToEndTestingExtensionInput, PotentiallyPartialResult, DynamicPropsExtensionInput

The main role of LayoutState is to hold the output of layout calculation. This includes mountable outputs and visibility outputs. A centerpiece of the class is LithoReducer#setSizeAfterMeasureAndCollectResults(ComponentContext, LithoLayoutContext, LayoutState) which prepares the before-mentioned outputs based on the provided LithoNode for later use in MountState.

Link copied to clipboard
class LayoutTextContentItem(layout: Layout, val text: CharSequence, val fullText: CharSequence, isExplicitlyTruncated: Boolean, val color: Int = layout.paint.color, isMounted: () -> Boolean = { true }) : TextContent.Item

A TextContent.Item read from the Layout a text component draws, shared by Litho's legacy text drawable and RenderCore's text view so both report text the same way.

Link copied to clipboard
class LayoutTreeFuture(resolveResult: ResolveResult, currentLayoutState: LayoutState?, diffTreeRoot: DiffNode?, widthSpec: Int, heightSpec: Int, treeId: Int, treeState: TreeState, version: Int, source: Int, debugBreadcrumb: String? = null) : TreeFuture<LayoutState>
Link copied to clipboard
class LithoAnimtableItem(id: Long, absoluteBounds: Rect, outputType: Int, nodeInfo: NodeInfo?, transitionId: TransitionId?, bounds: Rect = absoluteBounds) : 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?)
Link copied to clipboard
class LithoExtraContextForLayoutScope : ResolvedLayoutDirectionProvider
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
class LithoHostListenerCoordinator(mountDelegateTarget: MountDelegateTarget)

Helper for dispatching events to multiple MountListenerExtensions in Litho.

Link copied to clipboard
class LithoLayoutContext @JvmOverloads constructor(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<*>?, val scopesToUpdate: DirtyScopeIndex = DirtyScopeIndex.EMPTY) : 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 LithoLayoutData(val width: Int, val height: Int, val expandedTouchBounds: Rect?, val zIndex: Int?, 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
sealed interface LithoLayoutOutput

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
class LithoMetadataExceptionWrapper(componentContext: ComponentContext? = null, root: String? = null, logTag: String? = null, cause: Throwable) : RuntimeException

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
sealed class LithoRenderEffect

A Litho abstraction of RenderEffect. Android RenderEffect is a wrapper for native code, which means that the instances are never equal and if we pass such instances through Litho, it may break some of our optimizations which rely on object equivalence.

Link copied to clipboard
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.

Link copied to clipboard
value class LithoRendererLifecycle(val value: Int)
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

Registry of component state that can be snapshotted into Android saved state.

Link copied to clipboard

A lifecycle-backed namespace for state declared with useSaveableState.

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

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

Link copied to clipboard
Link copied to clipboard
open class LithoView @JvmOverloads constructor(val componentContext: ComponentContext, attrs: AttributeSet? = null) : BaseMountingView

A ViewGroup that can host the mounted state of a Component.

Link copied to clipboard

Owns AndroidX ViewModel instances used by Litho components.

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 visibility events and informs subscribed LithoVisibilityEventsListener when a visibility state changes.

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

Can observe lifecycle changes that a LithoVisibilityEventsController goes through.

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

Companion to LithoYogaMeasureFunction used by the CSS Flexbox §4.5 automatic minimum sizing probe. Registered on the underlying YogaNode alongside the regular measure function so Yoga's YGMinContentMeasureFunc invokes this when probing a flex item for its min-content contribution along the parent's main axis.

Link copied to clipboard

Components should implement an event of this type in order to receive Android long click events. The method is equivalent to the Android method View.OnLongClickListener.onLongClick

Link copied to clipboard
class ManualGlobalKey(val key: String, val position: Int, val parent: GlobalKey?) : GlobalKey

Structural key for components with a manual key (set via .key("...")). Unlike StringGlobalKey, this preserves the parent pointer so that structural descendant checks work across manual key boundaries without falling back to string prefix comparison.

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

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 treeState: TreeState?, var currentResolveResult: ResolveResult? = null, var currentLayoutState: LayoutState? = null)
Link copied to clipboard
class NestedLithoViewsExtension : MountExtension<Void?, Void?> , OnItemCallbacks<Void?>

MountExtension to ensure that content with nested LithoViews is properly clearing those LithoViews when the item is unmounted. Since this should only happen when unmounting an item and not when it's being updated, shouldUpdateItem is not overridden (defaulting to super implementation which returns false).

Link copied to clipboard
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

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 androidx.core.view.AccessibilityDelegateCompat.onInitializeAccessibilityEvent

Link copied to clipboard

Components should implement an event of this type in order to receive callbacks to androidx.core.view.AccessibilityDelegateCompat.onInitializeAccessibilityNodeInfo

Link copied to clipboard

Components should implement an event of this type in order to receive callbacks to androidx.core.view.AccessibilityDelegateCompat.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 androidx.core.view.AccessibilityDelegateCompat.onRequestSendAccessibilityEvent

Link copied to clipboard
open class Output<T>

Type for parameters that are logical outputs.

Link copied to clipboard
data class PendingStateUpdate(val stateId: StateId, 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 View.AccessibilityDelegate.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

Reports the text of an RCTextView mounted in a ComponentHost, so the host's TextContent covers primitive text the same way it covers Litho's legacy text drawable.

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
value class RenderMode

A class that represents the trigger type of the render call.

Link copied to clipboard

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

Identifies the render phase in which a hook executes.

Link copied to clipboard
annotation class RenderSource
Link copied to clipboard
Link copied to clipboard
class RenderState(from: RenderState? = null)

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 @JvmOverloads constructor(val treeId: Int, val cache: MeasuredResultCache, treeState: TreeState?, val layoutVersion: Int, val rootComponentId: Int, val isAccessibilityEnabled: Boolean, treeFuture: TreeFuture<*>?, val currentResolveResult: ResolveResult?, val isInLayout: Boolean, val scopesToUpdate: DirtyScopeIndex = DirtyScopeIndex.EMPTY, enclosingLayoutContext: LithoLayoutContext? = null) : 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 outputs: Resolver.Outputs?, val contextForResuming: ResolveContext?, val updatedStates: Set<StateId>, val isAccessibilityEnabled: Boolean = false) : PotentiallyPartialResult
Link copied to clipboard
class ResolveTreeFuture(componentContext: ComponentContext, component: Component, treeState: TreeState, currentResolveResult: ResolveResult?, resolveVersion: Int, useCancellableFutures: Boolean, componentTreeId: Int, extraAttribution: String?, source: Int, debugBreadcrumb: String? = null) : TreeFuture<ResolveResult>
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
typealias RowBuilder = Row

Migration scaffolding: a typealias for the legacy SpecGen Row class under a non-colliding name.

Link copied to clipboard

Converts a value to and from a representation supported by Android saved state.

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 androidx.core.view.AccessibilityDelegateCompat.sendAccessibilityEvent

Link copied to clipboard

Components should implement an event of this type in order to receive callbacks to androidx.core.view.AccessibilityDelegateCompat.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> : Value<T>

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

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
sealed interface StateUpdateApplier
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

StateUpdaterDelegator is responsible for holding reference to the right StateUpdater that will be used during creation of ComponentTree

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
class StringGlobalKey(val key: String) : GlobalKey

Wraps a full concatenated string key (current behavior). Used for all keys when the config flag is off (legacy/control path). Has no parent pointer -- structural traversal is not possible.

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

An interface for a View which supports setting and unsetting its transform pivot, even on pre-API 28 (P) devices.

Link copied to clipboard

A Component that wraps another component for testing purposes. This component has a lifecycle that doesn't override any methods except for isEquivalentTo().

Link copied to clipboard

Test implementation of ComponentScope used for testing purposes. Provides a test-specific context for component operations.

Link copied to clipboard
class TestItem

Holds information about a TestOutput.

Link copied to clipboard

This should be only used with the deprecated DiffNode based testing infrastructure. This class hosts a test implementation of create and resolve layout. The implementation only resolves the immediate subcomponents of the component. The implementation details of this class should be kept in sync with LayoutState if the existing tests written with the deprecated testing infrastructure are relevant.

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

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

Components should implement an event of this type in order to receive Android touch events. The method is equivalent to the Android method View.onTouchEvent - implementations should return true if they consumed the event and wish to receive subsequent events, and false otherwise. An example of the correct usage is:

Link copied to clipboard

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

Link copied to clipboard
abstract class TreeFuture<T : PotentiallyPartialResult>(treeId: Int, isInterruptionEnabled: Boolean)

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

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
fun interface UpdateSynchronizer
Link copied to clipboard
interface Value<out T>

A readonly observable value interface.

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

A component that can wrap a view using a ViewBinder class to bind the view and a ViewCreator to create the mount contents. This component will have a different recycle pool per ViewCreator instance.

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. This is useful for adding further CommonProps to an already created 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: YogaValue, val heightFromStyle: YogaValue, val minWidthFromStyle: YogaValue, val maxWidthFromStyle: YogaValue, val minHeightFromStyle: YogaValue, val maxHeightFromStyle: YogaValue, _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, _boundsDefined: Boolean = false, _contentRenderUnit: LithoRenderUnit? = null, _hostRenderUnit: LithoRenderUnit? = null, _backgroundRenderUnit: LithoRenderUnit? = null, _foregroundRenderUnit: LithoRenderUnit? = null, _borderRenderUnit: LithoRenderUnit? = null, _diffNode: DiffNode? = null, _delegate: LayoutResult? = null, _actualDeferredNodeResult: LithoLayoutResult? = null, _adjustedBounds: Rect = Rect(), _effects: List<Attachable>? = null) : 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
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val LayoutScope.layoutVersion: Int

Extension property to get the layout version from LayoutScope.

Link copied to clipboard
Link copied to clipboard

Hosts API to debug state

Link copied to clipboard

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

Wraps this existing ComponentContext in a ResourcesScope, for calling the ResourcesScope DSL (Row, Column, widgets such as Card) from code that already holds a ComponentContext but has no ambient ComponentScope — e.g. a @LayoutSpec helper or a builder-style function.

Link copied to clipboard
fun <ContentType : ViewGroup> MountConfigurationScope<ContentType>.bindToRenderTreeView(state: NestedLithoTreeState, getRenderTreeView: ContentType.() -> LithoRenderTreeView)
Link copied to clipboard
fun ComponentContext.boolAttr(@AttrRes attrResId: Int, @BoolRes defResId: Int = 0): Boolean

Return a boolean for an attribute resource ID.

Link copied to clipboard

Return a boolean for a resource ID.

Link copied to clipboard
fun ComponentScope.calculate(component: Component, sizeConstraints: SizeConstraints): LayoutResult?
Link copied to clipboard

Return a ColorInt value, corresponding to an attribute resource ID. If given attribute ID can not be found, default color resource ID defResId is used.

Link copied to clipboard

Return a ColorInt value for a color resource ID.

Link copied to clipboard
fun <E : Any, R> create(onEvent: (E) -> R): EventHandler<E>
fun <E : Any, R> create(id: Int, params: Array<out Any?>?, onEvent: (E) -> R): EventHandler<E>
fun create(unit: LithoRenderUnit, bounds: Rect, padding: Rect?, layoutData: LithoLayoutData? = null, parent: RenderTreeNode? = null, poolScope: PoolScope = PoolScope.None): RenderTreeNode
Link copied to clipboard
fun ComponentContext.dimenAttr(@AttrRes id: Int, @DimenRes defResId: Int = 0): Dimen

Return a dimen for an attribute resource ID.

Link copied to clipboard

Resolve a dimen resource ID as a Dimen value.

Link copied to clipboard

Retrieve a android.graphics.drawable.Drawable, corresponding to an attribute resource ID, as a Drawable instance. If given attribute ID can not be found, default Drawable resource ID defResId is used.

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

Retrieve a android.graphics.drawable.Drawable for a resource ID 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, noinline tag: () -> String?): EventHandler<E>
inline fun <E : Any> eventHandler(noinline onEvent: (E) -> Unit, noinline tag: () -> String?, componentContext: ComponentContext?): EventHandler<E>
Link copied to clipboard
inline fun <E : Any, R> eventHandlerWithReturn(noinline onEvent: (E) -> R): EventHandler<E>

inline fun <E : Any, R> eventHandlerWithReturn(noinline onEvent: (E) -> R, componentContext: ComponentContext?): EventHandler<E>

Creates a result handler. A callback exception goes to componentContext's error handler and the dispatch returns null; without a context, the exception propagates to the caller.

Link copied to clipboard
fun ComponentContext.floatAttr(@AttrRes id: Int, @DimenRes defResId: Int = 0): Float
Link copied to clipboard
Link copied to clipboard

Returns the thread-safe Litho ViewModel store retained by this AndroidX owner.

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> ResourcesScope.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?, crossinline 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
fun ComponentContext.intAttr(@AttrRes id: Int, @IntegerRes defResId: Int = 0): Int
Link copied to clipboard
Link copied to clipboard
inline fun key(key: String, crossinline 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
inline fun <T : Any> legacyTreePropOf(): TreeProp<T?>
fun <T : Any> legacyTreePropOf(clazz: Class<T>): TreeProp<T?>
Link copied to clipboard
fun LithoConfiguration(context: Context, componentsConfig: ComponentsConfiguration = ComponentsConfiguration.defaultInstance, renderUnitIdGenerator: RenderUnitIdGenerator? = null): LithoConfiguration
Link copied to clipboard

Creates a lazily initialized saveable-state scope owned by this Activity.

Creates a lazily initialized saveable-state scope owned by this Fragment.

Link copied to clipboard
fun <T> mergeLists(a: List<T>?, b: List<T>?): List<T>?
Link copied to clipboard

Retrieve a android.graphics.drawable.Drawable for a resource ID as a Drawable instance, or null if the resource ID is zero or null.

Link copied to clipboard
inline fun NullableTreePropProvider(vararg props: TreePropValuePair<*>, crossinline component: () -> Component?): KComponent?
@JvmName(name = "NullableLegacyTreePropProvider")
inline fun NullableTreePropProvider(vararg props: ClassValuePair<*>, crossinline component: () -> Component?): KComponent?

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 ResourcesScope.NullableWrapper(name: String? = null, style: Style, crossinline content: ResourcesScope.() -> Component?): Wrapper?

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

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
operator fun <K, V> Map<K, V>?.plus(map: Map<K, V>?): Map<K, V>?
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
fun ComponentContext.quantityStringRes(@PluralsRes id: Int, quantity: Int, vararg formatArgs: Any?): String
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

Creates a standalone ResourcesScope from a plain Android Context, for building a detached component tree outside a KComponent.render / ComponentScope — e.g. a dialog or bottom sheet constructed from a click handler. Prefer the ambient ComponentScope whenever one is available; this is a compatibility escape hatch, hence the Compat suffix.

Link copied to clipboard
fun <T> Saver(save: (T) -> Any?, restore: (Any?) -> T): Saver<T>

Creates a Saver from its save and restore operations.

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 ComponentContext.stringAttr(@AttrRes attrResId: Int, @StringRes defResId: Int = 0): String

Return a string for an attribute resource ID.

Link copied to clipboard

Return a string for a resource ID.

Return a string for a resource ID, substituting the format arguments with arg.

fun ComponentContext.stringRes(@StringRes id: Int, vararg formatArgs: Any?): String

Return a string for a resource ID, substituting the format arguments with formatArgs.

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<*>, crossinline component: () -> Component): KComponent

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.

@JvmName(name = "LegacyTreePropProvider")
inline fun TreePropProvider(vararg props: ClassValuePair<*>, crossinline component: () -> Component): KComponent

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

This hook creates a set of references, one for each focusable component that can be used for changing the default focus order. Use with Style.focusOrder

Link copied to clipboard
fun ComponentScope.useHandle(vararg inputs: Any?): Handle

Returns a new, cached Handle instance if it hasn't already been provided or if the inputs have changed since the previous invocation of this method.

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.useSaveableState(key: String? = null, saver: Saver<T> = autoSaver(), initializer: () -> T): State<T>

Declares component state that can be restored by a lifecycle-backed host.

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
fun <T> ComponentScope.useStateWithDeps(vararg deps: Any? = NoDeps, initializer: () -> T): State<T>

Declares a state within a Component. The initializer will be invoked to provide the initial value of state. The initializer will be invoked again if the deps change when the Component is rendered again.

Link copied to clipboard
inline fun <T : ViewModel> ComponentScope.useViewModel(key: String? = null, noinline factory: () -> T): ReadOnlyProperty<Any?, T>

Declares a ViewModel scoped to the store supplied by the tree's host. Root trees supply a LithoViewModelStore through ComponentTree.Builder.withLithoViewModelStore, while nested trees receive their current inherited store through TreeProps.

Link copied to clipboard
inline fun <R> ComponentScope.withNewScope(key: Any, block: ComponentScope.() -> R): R

Gives every hook called by block an identity nested under key. Use this when the same source hook call renders several logical items whose order can change. The key must be immutable, stable across renders, and unique among invocations of this withNewScope call site under the same parent scope. Duplicate sibling keys are reported and disambiguated by their order. Two different call sites may use the same key without colliding.

Link copied to clipboard
Link copied to clipboard
inline fun ResourcesScope.Wrapper(name: String? = null, style: Style, crossinline content: ResourcesScope.() -> Component): Wrapper

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