Skip to content

Instantly share code, notes, and snippets.

@gustavo-depaula
Created October 28, 2019 17:50
Show Gist options
  • Save gustavo-depaula/9a8db22cf1e2f2ff4583bb710ff767e7 to your computer and use it in GitHub Desktop.
Save gustavo-depaula/9a8db22cf1e2f2ff4583bb710ff767e7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const signatureMachine = Machine({
id: 'signature',
initial: 'init',
context: {
signature: null,
isExpectedRecipient: null
},
states: {
init: {
on: {
NEXT: 'signature',
BACK: {
actions: [
sendParent('BACK')
]
}
}
},
signature: {
on: {
BACK: 'init',
SAVE_SIGNATURE: {
target: 'confirmation',
actions: assign({
signature: (_, { signature }) => signature
})
}
}
},
confirmation: {
on: {
BACK: 'signature',
CONFIRM_RECIPIENT: {
actions: [
assign({
isExpectedRecipient: (_, { isExpectedRecipient }) =>
isExpectedRecipient
}),
sendParent('SIGNATURE.INFO',)
]
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment