bottender-xstate
Installation
npm install bottender-xstate
API Reference
Param | Type | Description |
---|---|---|
config | XstateConfig |
Config to be passed to xstate. |
mapContextToXstateEvent | Function |
Mapper for create xstate event from context. |
actions | Object |
Map of named actions. |
guards | Object |
Map of named guards. |
events | Array<String> |
All events handled by the machine. (required when using * (catch-all) event) |
onEvent | Function |
Callback to be called when trigger event. |
onAction | Function |
Callback to be called when trigger action. |
const bottenderXstate = ; const config = id: 'light' initial: 'green' states: green: on: TIMER: target: 'yellow' onEntry: 'enterGreen' onExit: 'leaveGreen' yellow: on: TIMER: target: 'red' onEntry: 'enterYellow' onExit: 'leaveYellow' red: on: TIMER: target: 'green' actions: 'fromRedToGreen' onEntry: 'enterRed' onExit: 'leaveRed' ; const mapContextToXstateEvent = 'TIMER'; const actions = context context context context context context context; bot;
You can find more examples in the examples folder.
License
MIT © Yoctol