Skip to content

Instantly share code, notes, and snippets.

@Fishbiscuit
Last active November 4, 2019 07:31
Show Gist options
  • Save Fishbiscuit/d6a5d582d4d053e904b353131d0ce41f to your computer and use it in GitHub Desktop.
Save Fishbiscuit/d6a5d582d4d053e904b353131d0ce41f 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 checkpointStates = {
initial: 'wait',
states: {
wait: {
on: {
10: 'check'
}
},
check: {
on: {
10: 'clear'
}
},
clear: {}
}
};
const accident = {
initial: 'wait',
states: {
wait: {
on: {
10: 'evaluate'
}
},
evaluate: {
on: {
10: 'decide'
}
},
decide: {}
}
};
const fetchMachine = Machine({
id: 'Car',
initial: 'Enter',
context: {
retries: 0
},
states: {
Enter: {
on: {
Move: 'Queue'
}
},
Queue: {
on: {
Open: 'Checkpoint',
Incident: 'Accident',
}
},
Accident: {
on: {
Minor: 'Checkpoint',
Severe: 'Removed'
},
...accident
},
Checkpoint: {
on: {
Cleared: 'Exit',
Failed: 'Detained'
},
...checkpointStates
},
Exit: {
type: 'final'
},
Detained: {
type: 'final'
},
Removed: {
type: 'final'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment