ComponentUtils

Functions

Link copied to clipboard
fun areArraysEquals(classType: Class<*>, val1: Any?, val2: Any?): Boolean
Link copied to clipboard
Link copied to clipboard
fun arePropsEquivalent(props1: Array<*>, props2: Array<*>, shouldCompareCommonProps: Boolean = ComponentsConfiguration.shouldCompareCommonPropsInIsEquivalentTo): Boolean
Link copied to clipboard
Link copied to clipboard

Utility to dispatch an error event to a component. To be used by the generated component.

Utility to dispatch an unhandled exception to a component. To be used by the framework.

Link copied to clipboard

Utility to get a component to handle an exception gracefully outside the layout phase. If the component re-raises the exception using raise(ComponentContext, Exception) then the utility will rethrow the exception out of Litho.

Link copied to clipboard
fun handleWithHierarchy(parent: ComponentContext, component: Component?, exception: Exception)

Utility to get a component to handle an exception gracefully during the layout phase when dealing with component hierarchy.

Link copied to clipboard

Given two object instances of the same type, this method accesses all their internal fields, to check if they are equivalent. There's special equality code to handle special class types e.g. Components, EventHandlers, etc. Components are considered equivalent if they have the same props.

Link copied to clipboard
fun hasEquivalentState(stateContainer1: StateContainer?, stateContainer2: StateContainer?): Boolean
Link copied to clipboard
fun isEquivalent(current: Component?, next: Component?, shouldCompareCommonProps: Boolean = ComponentsConfiguration.shouldCompareCommonPropsInIsEquivalentTo): Boolean

Given two components this method accesses all their internal fields, excluding the fields of StateContainer if the class type is a Component, to check if they are equivalent. There's special equality code to handle special class types e.g. Components, EventHandlers, etc.

Link copied to clipboard

Calculate the level of the target Component/Section. The level here means how many bracket pairs are needed to break until reaching the component type. For example, the level of List is 1, and the level of List> is 2.

Link copied to clipboard

Reraise an error event up the hierarchy so it can be caught by another component, or reach the root and cause the application to crash.

Link copied to clipboard

Utility to re-throw exceptions.

Link copied to clipboard
Link copied to clipboard

Uses the given ComponentTree to add metadata to a wrapper exception (if the wrapper doesn't already exist) and return it.

Uses the given ComponentContext to add metadata to a wrapper exception (if the wrapper doesn't already exist) and return it.