Modules@robinpath/state

@robinpath/state

0.1.0Public

Finite state machine with transitions, guards, actions, context, history, and event listeners

@robinpath/state

Finite state machine with transitions, guards, actions, context, history, and event listeners

Category Functions Auth License

Why use this module?

The state module lets you:

  • Create state machine
  • Send event to trigger transition
  • Get current state
  • Get machine context
  • Check if event can be sent

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/state

Quick Start

No credentials needed — start using it right away:

state.send "next" "light"

Available Functions

FunctionDescription
state.createCreate state machine
state.sendSend event to trigger transition
state.currentGet current state
state.contextGet machine context
state.setContextSet machine context
state.canCheck if event can be sent
state.eventsGet available events from current state
state.isCheck if in specific state
state.resetReset to initial state
state.historyGet transition history
state.addTransitionAdd transition at runtime
state.addStateAdd state at runtime
state.onListen for transitions
state.serializeSerialize machine to JSON
state.matchesCheck if current state matches any
state.destroyDestroy machine
state.listList all machines

Examples

Send event to trigger transition

state.send "next" "light"

Get current state

state.current "light"

Get machine context

state.context "light"

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/state";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  state.send "next" "light"
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/state
Version0.1.0
LicenseMIT
Unpacked Size5.4 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

devops