Beagle v1.5 is no longer actively maintained. The documented version you are viewing may contain deprecated functionality. For up-to-date documentation, see the latest version .
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.
To create a custom action, follow the next steps:
action
interface:struct CustomAction: Action {
func execute(
controller: BeagleController,
origin: UIView) {
print("Custom action foi chamada!")
}
}
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;
Now, it is necessary to register this new action on Beagle’s dependencies:
let dependencies = BeagleDependencies()
dependencies.decoder.register(
action: CustomAction.self,
named: "CustomAction"
)
Beagle.dependencies = dependencies
See below an example on how to use the button that runs the customized action on the click event:
Button(
text: "do request",
onPress: [
CustomCAction()
]
)
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.