hisma_console_monitor 0.2.0+4 copy "hisma_console_monitor: ^0.2.0+4" to clipboard
hisma_console_monitor: ^0.2.0+4 copied to clipboard

Simple state machine monitor implementation that writes to the console for the Hisma package.

Simple monitor implementation for the Hisma package.

Features #

Prints out to console (or onto anything else you define. e.g. a logger) the active states of the hierarchical state machines of the program:

hisma_console_monitor_in_action.gif

Getting started #

Create your state machines with hisma.

Usage #

You can enable [ConsoleMonitor] by adding a creator function that returns ConsoleMonitor to the list of monitor creators (example code from hisma examples):

Future<void> main() async {
  StateMachine.monitorCreators = [
    (machine) => ConsoleMonitor(machine),
  ];

  await lightMachine.start();
  play();
}

This will result that state machine creation and active state changes will be monitored by ConsoleMonitor, writing out all active states of all hierarchical state machines of the program.

One can easily modify how [ConsoleMonitor] prints out the active states, e.g. you can use your logger instead of printing to consoles. In the following example we add an extra separator line before each output of active states:

Future<void> main() async {
  StateMachine.monitorCreators = [
    (machine) => ConsoleMonitor(
          machine,
          printer: (str) {
            print('-MONITOR----------------------------');
            print(str);
          },
        ),
  ];

  await lightMachine.start();
  play();
}

Additional information #

If you have any questions, comments please go to Hisma GitHub Discussions to start or join discussions.

0
likes
140
pub points
27%
popularity

Publisher

unverified uploader

Simple state machine monitor implementation that writes to the console for the Hisma package.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

hisma

More

Packages that depend on hisma_console_monitor