Skip to content

Instantly share code, notes, and snippets.

@parker-codes
Created June 16, 2020 02:23
Show Gist options
  • Select an option

  • Save parker-codes/cb61aac756eeab0e9c4d4e00875b208e to your computer and use it in GitHub Desktop.

Select an option

Save parker-codes/cb61aac756eeab0e9c4d4e00875b208e to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const increment = context => context.count + 1;
const decrement = context => context.count - 1;
const reset = context => context.count = 0;
const counterMachine = Machine({
initial: 'active',
context: {
count: 0
},
states: {
active: {
on: {
INC: { actions: assign({ count: increment }) },
DEC: { actions: assign({ count: decrement }) },
RESET: { actions: assign({ count: reset }) }
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment