FromBoundsDefined

FromBoundsDefined is used to pass objects from the OnBoundsDefined lifecycle methods of MountSpec to lifecycle methods called successively such as OnMount or OnBind method, use FromBoundsDefined 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 OnBoundsDefined. 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 FromBoundsDefined 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);
  }


 @OnBoundsDefined
  void onBoundsDefined(
      ComponentContext c,
      ComponentLayout layout,
      Output<MyFromBoundsDefinedObject> fromBoundsDefinedObject) {
    MyFromBoundsDefinedObject myFromBoundsDefinedObject = new MyFromBoundsDefinedObject();
    fromBoundsDefinedObject.set(myFromBoundsDefinedObject);
  }

 @OnMount
  void onMount(
      ComponentContext c,
      MyDrawable myDrawable,
      @FromBoundsDefined MyFromBoundsDefinedObject fromBoundsDefinedObject) {
    fromBoundsDefinedObject.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