Events

Here you’ll find descriptions of what events are and its types.

What are events?

What are they? Events are anything that can trigger actions on Beagle (Beagle Actions). In the JSON, every key is associated to a Beagle Action that represents an event.

See some events example:

  • onPress
  • onError
  • onFocus
  • onChange

An event can be part of the component contract or a Beagle action. Abutton, for example, is a component onPress and is an event that it is part of its contract. An action sendRequest, it’s an example of action in which the events “onSuccess”, “onError” and “onFinish” are part of the contract.

How to use it?

See the example with the event onPress button:

Button(
    text = "Click to show message",
    onPress = listOf(
        Alert(
            title = "I'm an alert",
            message = "Hello Beagle"
        )
    )
)

The example above associates the action “beagle:alert” to the event onPress of the beagle:button component. When you press the button where the title is “Click to show message”, a message will be shown on the screen with the text “Hello World!”.

Every event in any component or action can be associated with any Beagle Action. An alert action was used in the previous example, but any other can be used. To make a request when clicking the button, the action “beagle:sendRequest” could be used. For more information about all available actions, access here.


Last modified February 11, 2021: create content (#298) (43225e15)