Skip to content

Commit

Permalink
Add JavaDoc to Param
Browse files Browse the repository at this point in the history
Summary: Add JavaDoc to Param

Reviewed By: colriot, marco-cova

Differential Revision: D15335486

fbshipit-source-id: 6c4ad3560a33678ca4d0b78a7bd8095484ac1b5a
  • Loading branch information
adityasharat authored and facebook-github-bot committed May 14, 2019
1 parent c78580c commit 253ac70
Showing 1 changed file with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,42 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* Params can be used together with {@link Event} callbacks i.e. {@code EventHandler}. An argument
* in the event handler annotated with {@code Param} will add it in the generated {@code 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.
*
* <p><b>For Example:</b> <br>
*
* <pre><code>{@literal @LayoutSpec}
* class FacePileComponentSpec {
*
* {@literal @OnCreateLayout}
* static Component onCreateLayout(
* LayoutContext c,
* {@literal @Prop} Uri[] faces) {
*
* Component.Builder builder = Column.create(c);
* for (Uri face : faces) {
* builder.child(
* FrescoImage.create(c)
* .uri(face)
* .clickHandler(FacePileComponent.onFaceClicked(c, face));
* }
*
* return builder.build();
* }
*
* {@literal @OnEvent(ClickEvent.class)}
* static void onFaceClicked(
* ComponentContext c,
* {@literal @Param} Uri face) {
*
* // Use the param face here
* Log.d("FacePileComponent", "Face clicked: " + face);
* }
* }</code></pre>
*/
@Retention(RetentionPolicy.CLASS)
public @interface Param {

}
public @interface Param {}

0 comments on commit 253ac70

Please sign in to comment.