Action0<State, System, R> constructor

Action0<State, System, R>(
  1. String description, {
  2. required FutureOr<void> nextState(
    1. State
    ),
  3. required FutureOr<R> run(
    1. System
    ),
  4. FutureOr<bool> precondition(
    1. State
    )?,
  5. FutureOr<bool> postcondition(
    1. State,
    2. R
    )?,
})

Creates a new action command with no arbitrary.

Parameters:

  • description: The description of the action.
  • nextState: A function to update the state.
  • run: A function to perform the action.
  • precondition: A function to test the precondition of the action.
  • postcondition: A function to test the postcondition of the action.

Implementation

Action0(
  String description, {
  required FutureOr<void> Function(State) nextState,
  required FutureOr<R> Function(System) run,
  FutureOr<bool> Function(State)? precondition,
  FutureOr<bool> Function(State, R)? postcondition,
}) : super(
        description,
        null,
        nextState: (s, _) => nextState(s),
        run: (sys, _) => run(sys),
        precondition: (s, _) =>
            asyncCallOr(() => precondition?.call(s), true),
        postcondition: (s, _, r) =>
            asyncCallOr(() => postcondition?.call(s, r), true),
      );