Skip to content

Instantly share code, notes, and snippets.

@davidlav
Last active February 3, 2020 16:49
Show Gist options
  • Select an option

  • Save davidlav/e59bcb81a7d79dadd2b1d06a1f9e55ec to your computer and use it in GitHub Desktop.

Select an option

Save davidlav/e59bcb81a7d79dadd2b1d06a1f9e55ec to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'exampleMachine',
initial: 'start',
context: {
approved: false,
},
states: {
start: {
on: {
SUBMITTED: 'stepOne'
},
},
stepOne: {
on: {
STEP_ONE_DONE: 'stepTwo',
},
},
stepTwo: {
on: {
STEP_TWO_DONE: 'awaitingApproval',
},
},
awaitingApproval: {
on: {
'': {
target: 'success',
cond: 'isApproved'
}
}
},
success: {
type: 'final'
},
},
on: {
APPROVAL_GIVEN: {
actions: assign({
approved: true
}),
target: undefined
}
}
}, {
guards: {
isApproved: ctx => ctx.approved === true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment