@Retention(value=CLASS)
public @interface Param
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);
}
}