Skip to content

Instantly share code, notes, and snippets.

@barbados-clemens
Last active June 4, 2020 22:19
Show Gist options
  • Save barbados-clemens/044b87e2642e2911e4f598218ad9ec19 to your computer and use it in GitHub Desktop.
Save barbados-clemens/044b87e2642e2911e4f598218ad9ec19 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 steakMachine = Machine({
id: 'steak',
initial: 'uncooked',
context: {
temp: 100
},
states: {
uncooked: {
on: {
'': {
target: 'rare',
cond: (ctx, event) => ctx.temp > 120,
},
HEAT: {
target: 'uncooked',
actions: [
assign({
temp: (ctx, event) => ctx.temp + 5
})
]
}
}
},
rare: {
on: {
'': {
target: 'mediumRare',
cond: (ctx, event) => ctx.temp > 131,
},
HEAT: {
target: 'rare',
actions: [
assign({
temp: (ctx, event) => ctx.temp + 5
})
]
}
}
},
mediumRare: {
on: {
'': {
target: 'medium',
cond: (ctx, event) => ctx.temp > 141,
},
HEAT: {
target: 'mediumRare',
actions: [
assign({
temp: (ctx, event) => ctx.temp + 5
})
]
}
}
},
medium: {
on: {
'': {
target: 'wellDone',
cond: (ctx, event) => ctx.temp > 151,
},
HEAT: {
target: 'medium',
actions: [
assign({
temp: (ctx, event) => ctx.temp + 5
})
]
}
}
},
wellDone: {
type: 'final'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment