Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlsson
Created September 22, 2021 14:13
Show Gist options
  • Save sebastiancarlsson/c34261d35f6c6dd3e83d1de9afd62d01 to your computer and use it in GitHub Desktop.
Save sebastiancarlsson/c34261d35f6c6dd3e83d1de9afd62d01 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const todoMachine = Machine({
initial: 'pending',
context: {
description: 'This is my todo'
},
states: {
pending: {
on: {
DONE: 'done',
SET_DESCRIPTION: {
actions: assign({
description: (ctx, evt) => evt.text
})
}
}
},
done: {
on: {
UNDO: 'pending'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment