Skip to content

Instantly share code, notes, and snippets.

@s-m-i-t-a
Created March 18, 2020 11:21
Show Gist options
  • Save s-m-i-t-a/3e924807ecb01c5dcb3e685f191bdcbf to your computer and use it in GitHub Desktop.
Save s-m-i-t-a/3e924807ecb01c5dcb3e685f191bdcbf 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 doubleCounterMachine = Machine({
id: "doubleCounter",
initial: "idle",
context: {count: 0},
states: {
idle: {
on: {
INC_COUNT_TWICE: {
actions: [
ctx => console.log("before", ctx.count),
"inc",
"inc",
ctx => console.log("after", ctx.count)
]
}
}
}
}
},
{
actions: {
inc: assign({
count: context => context.count + 1
})
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment