fsmfy

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 14 Imported by: 0

README

FSMFY

This is a Go generator tool to create a Golang type-safe code for Xstate JS library.

The implementation is using "github.com/looplab/fsm" library, which is not 100% compatible with XState. Nevetheless it works fine for simple sate machines.

How to use

To make it works you need to install fmsfy tool:

go install github.com/MadAppGang/fsmfy

As usual go generator add the line in any go file:

//go:generate fsmfy test.json MyFSM

The first argument test.json is FSM machine description from XState JS library. You can gran XState machine and run in console: JSON.stringify(machine).

The second argument is your FSM type name.

and run:

go generate ./...

All done.

Limitations

Xstate supports events with multi-source and multi-destinations states. For example one event could be initiated from the list of states and lead to the other states.

In go library it is not supported, the event could be sourced in a list of states but lead only to one state. If you have incompatible event - the tool will fail with error.

Documentation

Overview

Code generated by "fsmfy.go"; DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL