Skip to content

Golang generator to convert XState JS library State machine to golang code

License

Notifications You must be signed in to change notification settings

MadAppGang/fsmfy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Golang generator to convert XState JS library State machine to golang code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages