Last active
June 4, 2020 22:19
-
-
Save barbados-clemens/044b87e2642e2911e4f598218ad9ec19 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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