Action0<State, System, R> constructor

Action0<State, System, R>(
  1. String description, {
  2. required void nextState(
    1. State
    ),
  3. required R run(
    1. System
    ),
  4. bool precondition(
    1. State
    )?,
  5. 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 void Function(State) nextState,
  required R Function(System) run,
  bool Function(State)? precondition,
  bool Function(State, R)? postcondition,
}) : super(
        description,
        null,
        nextState: (s, _) => nextState(s),
        run: (sys, _) => run(sys),
        precondition: (s, _) => precondition?.call(s) ?? true,
        postcondition: (s, _, r) => postcondition?.call(s, r) ?? true,
      );