Skip to content

Instantly share code, notes, and snippets.

@ekafyi
Created July 21, 2020 18:56
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 ekafyi/06ae8ab6a681d88518cb1f4687c7ddf1 to your computer and use it in GitHub Desktop.
Save ekafyi/06ae8ab6a681d88518cb1f4687c7ddf1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const tapStates = {
initial: 'tapOff',
states: {
tapOff: {
on: {
TAP_ON: 'tapOn'
}
},
tapOn: {
on: {
TAP_OFF: 'tapOff'
}
}
}
};
const soapStates = {
initial: 'soapOff',
states: {
soapOff: {
on: {
SOAP_ON: 'soapOn'
}
},
soapOn: {
on: {
SOAP_OFF: 'soapOff'
}
}
}
};
const washingSubstates = {
type: 'parallel',
states: {
tapStates,
soapStates
}
}
const handWashMachine4 = Machine({
id: 'handwash',
initial: 'unwashed',
states: {
unwashed: {
on: {
START_WASH: 'washing'
}
},
washing: {
on: {
STOP_WASH: 'unwashed'
},
after: {
20000: 'washed'
},
...washingSubstates
},
washed: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment