Topics covered:
Requirements:
To create an action with asynchronous execution such as consuming an API or accessing a database, follow the steps:
Step 1: Create an action
as usual, just like the previous example;
Step 2: Implement the AsyncAction
interface;
Step 3: Link the AsyncAction
interface and delegate its implementation to the AsyncActionImpl
class provided by Beagle.
onActionStarted
and onActionFinished
, exposing its state in a reactive and standardized way in the framework.@RegisterAction("customActionAndroid")
data class CustomActionAndroid(
val value: String
) : Action, AsyncAction by AsyncActionImpl() {
override fun execute(rootView: RootView) {
// Do asynchronous work
}
}
Step 4: Now, the action is ready to execute asynchronously. It is MANDATORY to notify when the execution is finished through the onActionFinished
method.
@RegisterAction("customActionAndroid")
data class CustomActionAndroid(
val value: String
) : Action, AsyncAction by AsyncActionImpl() {
override fun execute(rootView: RootView) {
// Do asynchronous work
onActionFinished()
}
}
It’s done! Your action is now configured to run any job asynchronously!
AsyncAction
interface for any custom action that is inserted within the ListView component.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.