looplab / Fsm
Licence: apache-2.0
Finite State Machine for Go
Stars: ✭ 1,269
Programming Languages
go
31211 projects - #10 most used programming language
Labels
Projects that are alternatives of or similar to Fsm
Fsm As Promised
A finite state machine library using ES6 promises
Stars: ✭ 446 (-64.85%)
Mutual labels: finite-state-machine, fsm
use-state-machine
Use Finite State Machines with React Hooks
Stars: ✭ 28 (-97.79%)
Mutual labels: fsm, finite-state-machine
FiniteStateMachine
This project is a finite state machine designed to be used in games.
Stars: ✭ 45 (-96.45%)
Mutual labels: fsm, finite-state-machine
Libfsm
DFA regular expression library & friends
Stars: ✭ 512 (-59.65%)
Mutual labels: finite-state-machine, fsm
UnityHFSM
A simple yet powerful class based hierarchical finite state machine for Unity3D
Stars: ✭ 243 (-80.85%)
Mutual labels: fsm, finite-state-machine
visual-automata
Visual Automata is a Python 3 library built as a wrapper for the Automata library to add more visualization features.
Stars: ✭ 55 (-95.67%)
Mutual labels: fsm, finite-state-machine
as fsm
A finite state machine implementation for elixir
Stars: ✭ 14 (-98.9%)
Mutual labels: fsm, finite-state-machine
Fluent State Machine
Fluent API for creating state machines in C#
Stars: ✭ 195 (-84.63%)
Mutual labels: finite-state-machine, fsm
simple-state-machine
A simple Java state machine for Spring Boot projects
Stars: ✭ 25 (-98.03%)
Mutual labels: fsm, finite-state-machine
fsm
Finite State Machine for Go inspired by Akka FSM
Stars: ✭ 59 (-95.35%)
Mutual labels: fsm, finite-state-machine
Stateless4j
Lightweight Java State Machine
Stars: ✭ 658 (-48.15%)
Mutual labels: finite-state-machine, fsm
Statecharts.github.io
There is no state but what we make. Feel free to pitch in.
Stars: ✭ 265 (-79.12%)
Mutual labels: finite-state-machine, fsm
Floatsidebar.js
Lightweight (2kb gzipped), zero-dependency javascript library for making float sidebars based on the finite state machine
Stars: ✭ 56 (-95.59%)
Mutual labels: finite-state-machine, fsm
stateless
Finite State Machine porting from Stateless C#
Stars: ✭ 25 (-98.03%)
Mutual labels: fsm, finite-state-machine
raider
OWASP Raider: a novel framework for manipulating the HTTP processes of persistent sessions
Stars: ✭ 88 (-93.07%)
Mutual labels: fsm, finite-state-machine
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+1577.38%)
Mutual labels: fsm, finite-state-machine
Django Fsm
Django friendly finite state machine support
Stars: ✭ 1,898 (+49.57%)
Mutual labels: finite-state-machine, fsm
Nanostate
🚦- Small Finite State Machines
Stars: ✭ 151 (-88.1%)
Mutual labels: finite-state-machine, fsm
pastafarian
A tiny event-based finite state machine
Stars: ✭ 20 (-98.42%)
Mutual labels: fsm, finite-state-machine
statemachine-go
🚦 Declarative Finite-State Machines in Go
Stars: ✭ 47 (-96.3%)
Mutual labels: fsm, finite-state-machine
FSM for Go
FSM is a finite state machine for Go.
It is heavily based on two FSM implementations:
-
Javascript Finite State Machine, https://github.com/jakesgordon/javascript-state-machine
-
Fysom for Python, https://github.com/oxplot/fysom (forked at https://github.com/mriehl/fysom)
For API docs and examples see http://godoc.org/github.com/looplab/fsm
Basic Example
From examples/simple.go:
package main
import (
"fmt"
"github.com/looplab/fsm"
)
func main() {
fsm := fsm.NewFSM(
"closed",
fsm.Events{
{Name: "open", Src: []string{"closed"}, Dst: "open"},
{Name: "close", Src: []string{"open"}, Dst: "closed"},
},
fsm.Callbacks{},
)
fmt.Println(fsm.Current())
err := fsm.Event("open")
if err != nil {
fmt.Println(err)
}
fmt.Println(fsm.Current())
err = fsm.Event("close")
if err != nil {
fmt.Println(err)
}
fmt.Println(fsm.Current())
}
Usage as a struct field
From examples/struct.go:
package main
import (
"fmt"
"github.com/looplab/fsm"
)
type Door struct {
To string
FSM *fsm.FSM
}
func NewDoor(to string) *Door {
d := &Door{
To: to,
}
d.FSM = fsm.NewFSM(
"closed",
fsm.Events{
{Name: "open", Src: []string{"closed"}, Dst: "open"},
{Name: "close", Src: []string{"open"}, Dst: "closed"},
},
fsm.Callbacks{
"enter_state": func(e *fsm.Event) { d.enterState(e) },
},
)
return d
}
func (d *Door) enterState(e *fsm.Event) {
fmt.Printf("The door to %s is %s\n", d.To, e.Dst)
}
func main() {
door := NewDoor("heaven")
err := door.FSM.Event("open")
if err != nil {
fmt.Println(err)
}
err = door.FSM.Event("close")
if err != nil {
fmt.Println(err)
}
}
License
FSM is licensed under Apache License 2.0
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].