Skip to content

Instantly share code, notes, and snippets.

@QMaximillian
Created May 2, 2020 20:11
Show Gist options
  • Save QMaximillian/78771f7956e58a4de2ee4ab231a62292 to your computer and use it in GitHub Desktop.
Save QMaximillian/78771f7956e58a4de2ee4ab231a62292 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const countMachine = Machine({
id: 'doubleCounter',
initial: 'idle',
context: {
count: 0
},
states: {
idle: {
on: {
INC_COUNT_TWICE: {
actions: [
ctx => console.log('before', ctx.count) ,
'incCount',
'incCount',
ctx => console.log('after', ctx.count)
]
}
}
}
}
}, {
incCount: assign({
count: context => context.count + 1
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment