Skip to content

Instantly share code, notes, and snippets.

@Sewdn
Created April 7, 2021 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sewdn/c5c9846feeaaba16c1cba3ac73488a31 to your computer and use it in GitHub Desktop.
Save Sewdn/c5c9846feeaaba16c1cba3ac73488a31 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const ticketStatusMachine = Machine({
id: 'ticketStatus',
initial: 'created',
context: {
rejections: 0
},
states: {
created: {
on: {
ACCEPT: 'accepted'
}
},
accepted: {
on: {
APPROVE: 'approved',
REJECT: {
target: 'rejected',
actions: assign({
rejections: (context, event) => context.rejections + 1
})
}
}
},
rejected: {
on: {
RETRY: 'created',
}
},
approved: {
on: {
REVIEW: 'reviewed'
}
},
reviewed: {
on: {
PUBLISH_PROVISIONAL: 'published_provisional',
PUBLISH: 'published',
REJECT: {
target: 'rejected',
actions: assign({
rejections: (context, event) => context.rejections + 1
})
}
}
},
published_provisional: {
on: {
PUBLISH: 'published',
RETRACT: {
target: 'rejected',
actions: assign({
rejections: (context, event) => context.rejections + 1
})
}
}
},
published: {
type: 'final'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment