Skip to content

Instantly share code, notes, and snippets.

@jacobparis
Created April 6, 2020 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobparis/5947d4bce0df8b946e5144cc6d485d6b to your computer and use it in GitHub Desktop.
Save jacobparis/5947d4bce0df8b946e5144cc6d485d6b 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 calculatorMachine = Machine({
id: 'calculator',
initial: 'results',
states: {
results: {
on: {
OPERAND: 'operand_a',
MINUS: 'operand_a.negative'
}
},
operand_a: {
on: {
OPERAND: {},
OPERATOR: 'operator'
},
initial: 'positive',
states: {
positive: {},
negative: {}
}
},
operator: {
on: {
OPERAND: 'operand_b',
MINUS: 'operand_b.negative'
}
},
operand_b: {
on: {
OPERAND: {},
OPERATOR: 'operator',
EQUALS: 'results'
},
initial: 'positive',
states: {
positive: {},
negative: {}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment