Last active
June 4, 2021 23:36
-
-
Save jonmumm/9b84392f2bb000ed40f9d8391b152288 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const tasksStateMachine = { | |
initial: "video1", | |
states: { | |
video1: { | |
initial: "in_progress", | |
states: { | |
in_progress: { | |
on: { | |
"video.end?id=3": "completed" | |
} | |
}, | |
completed: { | |
type: "final" | |
}, | |
} | |
}, | |
video2: { | |
initial: "locked", | |
states: { | |
locked: { | |
on: { | |
"video.end?id=1": "unlocked" | |
} | |
}, | |
unlocked: { | |
on: { | |
"video.start?id=2": "in_progress" | |
} | |
}, | |
in_progress: { | |
on: { | |
"video.end?id=2": "completed" | |
} | |
}, | |
completed: { | |
type: "final" | |
}, | |
} | |
}, | |
video3: { | |
initial: "locked", | |
states: { | |
locked: { | |
on: { | |
"video.end?id=2": "unlocked" | |
} | |
}, | |
unlocked: { | |
on: { | |
"video.start?id=3": "in_progress" | |
} | |
}, | |
in_progress: { | |
on: { | |
"video.end?id=3": "completed" | |
} | |
}, | |
completed: { | |
type: "final" | |
}, | |
} | |
}, | |
} | |
} | |
const trackStateMachine = Machine({ | |
id: 'example-ed-track-state-machine', | |
initial: 'locked', | |
states: { | |
locked: { | |
on: { | |
"visit.submit?treatment_type=ED": "unlocked" | |
} | |
}, | |
unlocked: { | |
on: { | |
"video.start?id=1": "in_progress" | |
} | |
}, | |
in_progress: { | |
...tasksStateMachine, | |
on: { | |
"video.end?id=3": "completed" | |
} | |
}, | |
completed: { | |
type: "final" | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment