statemachine

package
v0.0.0-...-10bc8b7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnErrorEvent = EventType("error")
)

Variables

View Source
var (
	ErrorEventDoesNotExist = "event type does not exist"
	ErrorCbExist           = "callback already registered"
)

Functions

This section is empty.

Types

type Action

type Action interface {
	Execute(event *Event) (interface{}, error)
	Type() EventType
}

type Callback

type Callback func(event Event) error

type Event

type Event struct {
	Type EventType
	Data interface{}
	Err  error
}

type EventType

type EventType string

type IStateMachine

type IStateMachine interface {
	Close() error
	Send(event *Event) error
	On(eventType EventType, cb Callback) error
}

func NewGameMachine

func NewGameMachine() IStateMachine

type StateMachine

type StateMachine struct {
	// contains filtered or unexported fields
}

func (*StateMachine) Close

func (machine *StateMachine) Close() error

func (*StateMachine) On

func (machine *StateMachine) On(eventType EventType, cb Callback) error

func (*StateMachine) Send

func (machine *StateMachine) Send(event *Event) error

Jump to

Keyboard shortcuts

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