Custom Action

You will find here how to create a CustomAction class and a description about the methods


action is a code block that can run when some event is defined. Beagle already has some by default, however it is possible to create your own customized action.


How to create a custom action?

To create a custom action, follow the next steps:

  1. Create a class that implements an action interface:
struct CustomAction: Action {
    func execute(
        controller: BeagleController, 
        origin: UIView) {
            print("Custom action foi chamada!")
  1. After that, the interface will request that the method execute is implemented. On this method the code block will be implemented, then your action will run;

  2. Now, it is necessary to register this new action on Beagle’s dependencies:

let dependencies = BeagleDependencies()
    action: CustomAction.self,
    named: "CustomAction"
Beagle.dependencies = dependencies

How to use it?

See below an example on how to use the button that runs the customized action on the click event:

    text: "do request",
    onPress: [

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