Last active
October 2, 2022 14:19
-
-
Save deanrad/df94010509d4d96b62a51491e85f77e2 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 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