Skip to content

Instantly share code, notes, and snippets.

@deanrad
Last active October 2, 2022 14:19
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 deanrad/df94010509d4d96b62a51491e85f77e2 to your computer and use it in GitHub Desktop.
Save deanrad/df94010509d4d96b62a51491e85f77e2 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 alarmClock = Machine({
context: {
hour: 1,
min: 30
},
initial: 'idle',
states: {
idle: {
on: {
'button.down': {
target: 'setting'
}
}
},
setting: {
on: {
'button.up': {
target: 'idle'
},
'inc.hour': {
actions:
assign({
hour: (context, event) => {
return context.hour + 1
}
})
},
'inc.min': {
actions:
assign({
min: (context, event) => {
return context.min + 1
}
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment