FromPrepare

FromPrepare is used to pass objects from the OnPrepare lifecycle methods of MountSpec to lifecycle methods called successively such as OnMount or method, use FromPrepare with the same type and name to retrieve your previously set

To use it, simply declare a parameter of type com.facebook.litho.Output<> within the method annotated with OnPrepare. com.facebook.litho.Output<> accepts a generic type which should be the type of the object you want to pass around. Then, in a successive lifecycle method, use FromPrepare with the same type and name to retrieve your previously set object.

This can be used in:

Example:

@MountSpec
public class MyComponentSpec {

 @OnCreateMountContent
  MyDrawable onCreateMountContent(Context context) {
    return new MyDrawable(c);
  }


 @OnPrepare
  void onPrepare(
      ComponentContext c,
      Output<MyFromPrepareObject> fromPrepareObject) {
    MyFromPrepareObject myFromPrepareObject = new MyFromPrepareObject();
    fromPrepareObject.set(myFromPrepareObject);
  }

 @OnMount
  void onMount(
      ComponentContext c,
      MyDrawable myDrawable,
      @FromPrepare MyFromPrepareObject fromPrepareObject) {
    fromPrepareObject.doSomething();
  }

}

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String