Skip to content

Instantly share code, notes, and snippets.

@sp3ber
Created May 14, 2020 10:07
Show Gist options
  • Select an option

  • Save sp3ber/3684755da457bea4d1a5d18a957678ca to your computer and use it in GitHub Desktop.

Select an option

Save sp3ber/3684755da457bea4d1a5d18a957678ca to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine(
{
id: 'osagoReport',
initial: 'introduction',
context: {
},
states: {
introduction: {
on: {
NEXT: 'chooseFormalizedWay',
},
},
chooseFormalizedWay: {
on: {
NEXT: [
{
target: 'euro',
cond: 'isEuro',
},
{
target: 'gibdd',
cond: 'isGibdd',
},
{
target: 'notFormalized',
cond: 'notFormalized',
},
],
BACK: 'introduction',
},
},
gibdd: {
initial: 'chooseCauser',
states: {
chooseCauser: {
on: {
BACK: '#osagoReport.chooseFormalizedWay',
NEXT: 'when',
},
},
when: {
on: {
BACK: 'chooseCauser',
NEXT: {
actions: 'submit',
},
},
},
},
},
euro: {
initial: 'chooseCauser',
states: {
chooseCauser: {
on: {
NEXT: 'chooseCrash',
BACK: '#osagoReport.chooseFormalizedWay',
},
},
chooseCrash: {
on: {
NEXT: 'when',
BACK: 'chooseCauser',
},
},
when: {
on: {
BACK: 'chooseCrash',
NEXT: {
actions: 'submit',
},
},
},
},
},
notFormalized: {
on: {
BACK: 'chooseFormalizedWay',
},
},
},
},
{
conditions: {
isGibdd: () => {},
notFormalized: () => {},
isEuro: () => {},
},
actions: {
submit: (context, { values: formValues }) => {
alert(JSON.stringify(formValues));
},
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment