getValueFunction<T> method

ActionValueFunction<T>? getValueFunction<T>(
  1. BuildContext context,
  2. dynamic actionSpec,
  3. Map state,
  4. Map? evaluatorContext,
)

Returns a ActionValueFunction<T> that executes an Action based on it's actionSpec.

Implementation

ActionValueFunction<T>? getValueFunction<T>(BuildContext context,
    dynamic actionSpec, Map state, Map? evaluatorContext) {
  if (actionSpec == null) return null;
  if (EditorBloc.editMode) return (v) {};
  if (actionSpec is ActionValueFunction<Object?>) return actionSpec;

  final nodeSpec =
      actionSpec is NodeSpec ? actionSpec : NodeSpec.fromMap(actionSpec);

  return (val) {
    if (actionSpec != null) {
      run(context, nodeSpec, state, val, evaluatorContext);
    }
  };
}