Skip to content

Lambda parameter #85

@TBSten

Description

@TBSten

Add a function type like () -> Unit to the default types that Gallery can display. This will enhance the Composable manual test review experience.

In addition, the following points should be kept in mind to create a more meaningful UI Catalog.

  • Provide some kind of feedback when an event occurs.
    • Display Snackbar.
    • Displays detailed information about the invoked event.
  • Support events with arguments and return value. This has a significant effect when MVI is employed.
  • It would be even better to have a UI like BottomSheet (or Drawer, Dialog) that lists the events that have occurred.
  • @Composable () -> Unit, so that lambdas such as A can also be accepted. It is very common for UI components to provide a Slot argument.
    • It would be better if the size, position, and number of elements to be placed were editable. This is because a Slot may have child elements of various sizes.

Usage example

val `MyButton with onEvent parameter` by story {
  // `lambdaParameter()` function by 
  val onClick: /* () -> Unit */ by lambdaParameter()

  // With type parameter
  val onIntent: (MyIntent) -> Unit by lambdaParameter<MyIntent, Unit>()

  // With return value
  val getMyData: /* () -> MyData */ by lambdaParameter<MyData>()

  // With event label
  //   - This is useful to distinguish between multiple parameters of a function type. 
  val onClickWithLabel: /* () -> Unit */ by parameter(label = "onClick" /* Might as well have it set up automatically. */)

  MyButton(
    onClick = onClick,
  )

  MyScreen(
    onIntent = onIntent,
    getMyData = getMyData,
  )
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions