Skip to content

Instantly share code, notes, and snippets.

@sp3ber
Created May 14, 2020 09:52
Show Gist options
  • Select an option

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

Select an option

Save sp3ber/d5f2c8cc726b7b60d036d80559749f6e 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: (context, args) => {
return;
return args.values.formalizedWay === 'euro';
},
},
{
target: 'gibdd',
cond: (context, args) => {
return;
return args.values.formalizedWay === 'gibdd';
},
},
{
target: 'notFormalized',
cond: (context, args) => {
return;
return args.values.formalizedWay === 'noop';
},
},
],
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',
},
},
},
},
{
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