Skip to content

Instantly share code, notes, and snippets.

@elsangedy
Created March 8, 2021 14:24
Show Gist options
  • Save elsangedy/77a8595c6ef29fbc79fbb91132fb8444 to your computer and use it in GitHub Desktop.
Save elsangedy/77a8595c6ef29fbc79fbb91132fb8444 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// INSTRUMENT
const fetchMachine = Machine(
{
id: 'device',
initial: 'connection',
context: {
retries: 0
},
states: {
connection: {
on: {
SELECT_DEVICE: 'extraction',
},
},
extraction: {
initial: 'semiAuto',
on: {
INCISION: 'incision',
CHANGE_CONNECTION: 'connection',
},
states: {
semiAuto: {
initial: 'idle',
on: {
CHANGE_MODE: 'manual',
},
states: {
idle: {
on: {
START: 'operation',
},
},
operation: {
on: {
FINISH: 'finished',
},
},
finished: {
type: 'final',
}
}
},
manual: {
initial: 'operation',
on: {
CHANGE_MODE: 'semiAuto',
},
states: {
operation: {
on: {
FINISH: 'finished',
},
},
finished: {
type: 'final',
},
},
},
}
},
incision: {
initial: 'operation',
on: {
EXTRACTION: 'extraction',
CHANGE_CONNECTION: 'connection',
},
states: {
operation: {
on: {
FINISH: 'finished',
},
},
finished: {
type: 'final',
},
}
},
},
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment