Skip to content

Instantly share code, notes, and snippets.

@llldc21
Last active January 22, 2020 14:34
Show Gist options
  • Save llldc21/f3de7344e7ab53ed406f50af486507a9 to your computer and use it in GitHub Desktop.
Save llldc21/f3de7344e7ab53ed406f50af486507a9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const initial = 'DRAFT'
const machine = Machine({
id: 'e-proposal-state-machine',
initial: initial,
context: {
proposal: this.proposal
},
states: {
DRAFT: {
on: {
READY: [
{
target: 'READY',
cond: this.verifyStatus
},
{
target: 'DRAFT'
}
],
DELETED: 'DELETED'
}
},
DELETED: {
type: "final",
},
READY: {
on: {
SEND: 'WAITING',
CANCELED: 'CANCELED'
},
type: "final"
},
CANCELED: {
on: {
NEWPROPOSAL: 'DRAFT'
},
type: "final"
},
WAITING: {
on: {
CANCELED: 'CANCELED',
ACCEPTED: 'ACCEPTED',
REFUSED: 'REFUSED'
}
},
ACCEPTED: {
on: {
UPDATEOTHERS: 'WAITING',
UPDATEACTORS: 'CANCELED'
},
type: "final"
},
REFUSED: {
on: {
NEWPROPOSAL: 'DRAFT'
},
type: "final"
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment