run method
Future<void>
run(
- BuildContext buildContext,
- NodeSpec action,
- Map state,
- Object? eventValue,
- Map? actionContext,
Starts the execution of an action
Implementation
@nonVirtual
Future<void> run(BuildContext buildContext, NodeSpec action, Map state,
Object? eventValue, Map? actionContext) async {
if (!await preRun(buildContext, action.props)) {
return;
}
if (!buildContext.mounted) {
log.severe("BuildContext is not mounted after preRun.");
return;
}
final runState = actionContext ?? {};
var currentValue = eventValue;
NodeSpec? currentAction = action.clone();
while (currentAction != null) {
if (!buildContext.mounted) {
log.severe(
"BuildContext is not mounted while trying to execute Action '${currentAction.type}' (${currentAction.id})");
return;
}
final context =
ActionContext(state, runState, currentValue, buildContext);
if (!await preExecute(currentAction, context)) {
break;
}
final result = await execute(currentAction, context);
currentAction = await postExecute(currentAction, result, context);
currentValue = result.returnData;
}
onExecuted();
}