How to create a new action

This section shows how to create a Custom Action that could be used in events and handled by the frontend application

Beagle offers a lot of default Actions, however you can create a custom action.

Creating a frontend action

To create an action on the front end of your application, you may check the section Simple Custom Action

Creating an action in the backend

To create this action in the backend and use it in a screen built there, your code should look like this:

@RegisterAction
data class CustomAction(
val msg: String? = null
) : Action

Check the example below for an Action set in a Button click:

{
  "_beagleComponent_": "beagle:button",
  "text": "Beagle Button",
  "onPress": [
    {
      "_beagleAction_": "custom:customAction",
      "msg": "Eu sou um Toast."
    }
  ]
}
Button(
   text = "Beagle Button",
   onPress = listOf(CustomAction("Eu sou um Toast"))
)

Last modified September 17, 2021: Reviewed Android section (#773) (e4c75e98)