Skip to content

Instantly share code, notes, and snippets.

@Siunami
Last active February 23, 2020 00:35
Show Gist options
  • Save Siunami/00eb48de71dd595bbb1439567397a2c7 to your computer and use it in GitHub Desktop.
Save Siunami/00eb48de71dd595bbb1439567397a2c7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const roomState = {
"WAITING":"WAITING",
"SUBMITQUESTIONS":"SUBMITQUESTIONS",
"RATEQUESTIONS":"RATEQUESTIONS",
"SUBMITANSWERS":"SUBMITANSWERS",
"RATEANSWERS":"RATEANSWERS",
"VIEW":"VIEW",
"FOLLOWUP":"FOLLOWUP",
"NEWEND":"NEWEND"
}
const fetchMachine = Machine({
id: 'fetch',
initial: 'WAITING',
context:{
roomState: roomState.WAITING,
host: "",
participants: [],
dat: [],
round: -1,
subround: -1,
ready: 0,
branch: [],
timerStarted: false
},
states: {
WAITING: {
on: {
update_state: 'SUBMITQUESTIONS'
}
},
SUBMITQUESTIONS: {
on: {
submitQuestion: 'RATEQUESTIONS'
}
},
RATEQUESTIONS: {
on: {
rateQuestion: 'SUBMITANSWERS'
}
},
SUBMITANSWERS: {
on: {
submitAnswer: 'RATEANSWERS'
}
},
RATEANSWERS: {
on: {
rateAnswer: 'VIEW'
}
},
VIEW: {
on: {
readyUp: 'NEWEND'
}
},
NEWEND: {
on:{
newQuestion: 'SUBMITQUESTIONS',
leave: 'DASHBOARD'
}
},
DASHBOARD: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment