fsm

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Machine

type Machine[S State, A any] struct {
	// contains filtered or unexported fields
}

Machine it lets change a behavior when the state changes

func (*Machine[S, A]) AddEndState

func (m *Machine[S, A]) AddEndState(state S)

AddEndState for transition applies for handler and terminates when the end state is reached

func (*Machine[S, A]) AddState

func (m *Machine[S, A]) AddState(state S, handler StateTransitionHandlerFunc[S, A])

AddState and associated with handler function for transition

func (*Machine[S, A]) MakeTransition

func (m *Machine[S, A]) MakeTransition(handlerArgs A)

MakeTransition with given arguments

type State

type State interface {
	~byte | ~int | string
}

State identifier, must be unique

type StateTransitionHandlerFunc

type StateTransitionHandlerFunc[S State, A any] func(A) (S, A)

StateTransitionHandlerFunc that handling transitions between states and returns new

Jump to

Keyboard shortcuts

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