public final class DataDiffSection<T> extends Section
DiffSectionSpec
that creates a changeSet diffing a generic List
of data.
This Section
emits the following events:
RenderEvent
whenever it needs a Component
to render a model T from the list of
data. Providing an handler for this OnEvent
is mandatory.
OnCheckIsSameItemEvent
whenever during a diffing it wants to check whether two items
represent the same piece of data.
OnCheckIsSameContentEvent
whenever during a diffing it wants to check whether two items
that represent the same piece of data have exactly the same content.
For example:
{@code
com.facebook.litho.sections.common.DataDiffSectionSpec
Modifier and Type | Class and Description |
---|---|
static class |
DataDiffSection.Builder<T> |
SectionLifecycle.StateContainer, SectionLifecycle.StateUpdate
Modifier and Type | Method and Description |
---|---|
static <T> DataDiffSection.Builder<T> |
create(SectionContext context) |
protected void |
generateChangeSet(SectionContext c,
ChangeSet changeSet,
Section _prevAbstractImpl,
Section _nextAbstractImpl)
This method will delegate to the
DiffSectionSpec
method annotated with OnDiff |
static EventHandler |
getOnCheckIsSameContentEventHandler(SectionContext context) |
static EventHandler |
getOnCheckIsSameItemEventHandler(SectionContext context) |
static EventHandler |
getRenderEventHandler(SectionContext context) |
String |
getSimpleName()
Mostly used by logging to provide more readable messages.
|
protected boolean |
isDiffSectionSpec() |
boolean |
isEquivalentTo(Section other)
Compares this section to a different one to check if they are the same
|
getChildren, getEventDispatcher, getGlobalKey, getScopedContext, getStateContainer, makeShallowCopy, makeShallowCopy, recordEventTrigger, setChildren, setCount, setGlobalKey, setKey, setScopedContext
acceptTriggerEvent, acquireDiff, acquireOutput, bindService, createChildren, createInitialState, createService, dataBound, dispatchLoadingEvent, dispatchOnEvent, getEventTrigger, getLoadingEventHandler, getService, getTreePropsForChildren, newEventHandler, newEventHandler, newEventTrigger, populateTreeProps, refresh, releaseDiff, releaseOutput, requestFocus, requestFocus, requestFocus, requestFocusWithOffset, requestFocusWithOffset, shouldUpdate, transferService, transferState, unbindService, viewportChanged
public String getSimpleName()
Section
getSimpleName
in class Section
public boolean isEquivalentTo(Section other)
Section
This is used to be able to skip rendering a section again. We avoid using the Object.equals(Object)
so we can optimize the code better over time since we don't have to
adhere to the contract required for a equals method.
isEquivalentTo
in class Section
other
- the component to compare topublic static <T> DataDiffSection.Builder<T> create(SectionContext context)
public static EventHandler getOnCheckIsSameContentEventHandler(SectionContext context)
public static EventHandler getOnCheckIsSameItemEventHandler(SectionContext context)
public static EventHandler getRenderEventHandler(SectionContext context)
protected void generateChangeSet(SectionContext c, ChangeSet changeSet, Section _prevAbstractImpl, Section _nextAbstractImpl)
SectionLifecycle
DiffSectionSpec
method annotated with OnDiff
generateChangeSet
in class SectionLifecycle
protected boolean isDiffSectionSpec()
isDiffSectionSpec
in class SectionLifecycle