Skip to content

Instantly share code, notes, and snippets.

@kauly
Last active October 28, 2020 02:16
Show Gist options
  • Save kauly/9e5da8e6bef713f11788d32b2d3a948d to your computer and use it in GitHub Desktop.
Save kauly/9e5da8e6bef713f11788d32b2d3a948d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'main',
initial: 'idle',
context: {
port: null,
outputStack: [],
inputStack: [],
},
states: {
idle: {
on: {
PORT_OPEN: 'ready'
}
},
ready: {
on: {
PORT_ERROR: 'port_error',
SEND_CMD: 'processing',
RECEIVED_CMD: 'processing',
}
},
processing: {
on: {
SEND_CMD_READY: 'sending',
RECEIVED_CMD_READY: 'receiving'
}
},
sending: {
on: {
SEND_CMD_SUCCESS: 'idle',
}
},
receiving: {
on: {
RECEIVED_CMD_SUCCESS: 'idle',
}
},
port_error: {},
cmd_error: {},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment