I have been reading Litho's documentation and I found this code example
@LayoutSpec(events = { ColorChangedEvent.class })
class ColorComponentSpec {
...
@OnCreateLayout
static ComponentLayout onCreateLayout(
Context c,
@Prop EventHandler colorChangedHandler,
@FromPrepare int color) {
...
ColorComponent.dispatchColorChangedEvent(
colorChangedHandler,
color);
...
}
}
What does the @FromPrepare annotation do?
EDIT: this is an error in the docs. @FromPrepare
should only be used in MountSpecs, not in LayoutSpecs.
@FromPrepare
gives you an output that was returned from the OnPrepare
method. You can read more about this pattern here: http://fblitho.com/docs/mount-specs#inter-stage-inputs-and-outputs