Requirements:
To create an asynchronous custom action in Beagle that works like an API, just create an action
like the example in Custom Action and implement the AsyncAction
interface.
After creating an action, you must implement the AsyncAction
interface. It will request to execute a method and the onFinish parameter will be implemented.
struct CustomAction: AsyncAction {
@AutoCodable
var onFinish: [Action]?
func execute(controller: BeagleController, origin: UIView) {
}
}
Now you MUST notify when its execution is completed by triggering the onFinish
action.
controller.execute(actions: self.onFinish, origin: origin)
Follow the Asynchronous Custom Action example below:
struct CustomAction: AsyncAction {
@AutoCodable
var onFinish: [Action]?
func execute(controller: BeagleController, origin: UIView) {
print("Custom action was called")
controller.execute(actions: self.onFinish, origin: origin)
}
}
Your action is now configured to perform any tasks asynchronously!
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.