1

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?

passy
  • 7,170
  • 5
  • 36
  • 38
Salim Mahboubi
  • 561
  • 7
  • 25

1 Answers1

5

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

Ian Childs
  • 66
  • 3
  • 1
    We've now removed this from the docs: https://github.com/facebook/litho/commit/872539968179b5cea46bde8cc813a0117d24f452 – passy May 10 '17 at 14:24