Skip to content

Instantly share code, notes, and snippets.

@barodeur
Last active November 28, 2019 19:07
Show Gist options
  • Save barodeur/87f6666ede47176fa3ffd445eb5f4e52 to your computer and use it in GitHub Desktop.
Save barodeur/87f6666ede47176fa3ffd445eb5f4e52 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: "dailyChallenge",
initial: "not_started",
context: {
remainingPrompts: 2
},
states: {
not_started: {
on: {
START: "playing"
}
},
playing: {
initial: "waiting",
states: {
waiting: {
after: {
2000: "prompt_displayed"
},
// on: {
// DISPLAY_PROMPT: "prompt_displayed"
// }
},
prompt_displayed: {
initial: "waiting_answer",
states: {
waiting_answer: {
on: {
ANSWER: "answered",
EXPIRES: "completed"
}
},
answered: {
on: {
ANSWER: {
target: "answered",
actions: assign({
id: (context, event) => event.id
})
},
NEXT: "completed",
EXPIRES: "completed"
}
},
completed: { type: "final" }
},
onDone: "waiting"
}
},
onDone: "completed"
},
completed: { type: "final" }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment