Skip to content

Instantly share code, notes, and snippets.

@rootart
Last active May 3, 2020 21:56
Show Gist options
  • Select an option

  • Save rootart/d1ecbba7c2d4b5c6cfc76d82a2773e24 to your computer and use it in GitHub Desktop.

Select an option

Save rootart/d1ecbba7c2d4b5c6cfc76d82a2773e24 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const triathlonMachine = Machine(
{
id: 'triathlonMachine',
initial: 'idle',
context: {
startTime: null,
transitionOneStart: null,
cyclingLegStart: null,
transitionTwoStart: null,
runningLegStart: null,
finishEnd: null,
dnfTime: null,
},
on: {
PULL_OUT: 'dnf',
cond: () => {}
},
states: {
idle: {
on: {
START: 'active.swimming',
}
},
dnf: {},
finished: {},
active: {
states: {
swimming: {
on: {
TRANSITION: 'cycling',
PULL_OUT: '#triathlonMachine.dnf',
}
},
cycling: {
on: {
TRANSITION: 'running',
PULL_OUT: '#triathlonMachine.dnf',
}
},
running: {
on: {
FINISH: '#triathlonMachine.finished',
PULL_OUT: '#triathlonMachine.dnf',
}
}
}
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment