Param

annotation class Param

Params can be used together with Event callbacks i.e. EventHandler. An argument in the event handler annotated with Param will add it in the generated Component. This will allow to pass relevant arguments to the event handler while dispatching events. This is especially useful when event handlers can be reused.

For Example:

@LayoutSpec
class FacePileComponentSpec {

 @OnCreateLayout
  static Component onCreateLayout(
      ComponentContext c,
     @Prop Uri[] faces) {

    Component.Builder builder = Column.create(c);
    for (Uri face : faces) {
      builder.child(
          FrescoVitoImage2.create(c)
              .uri(face)
              .clickHandler(FacePileComponent.onFaceClicked(c, face)));
    }

    return builder.build();
  }

 @OnEvent(ClickEvent.class)
  static void onFaceClicked(
      ComponentContext c,
     @Param Uri face) {

    // Use the param face here
    Log.d("FacePileComponent", "Face clicked: " + face);
  }
}

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