Skip to content

Instantly share code, notes, and snippets.

@deniaz
Created April 6, 2020 10:59
Show Gist options
  • Save deniaz/a5b454fab4c6d2566c0f0beaaa273b2c to your computer and use it in GitHub Desktop.
Save deniaz/a5b454fab4c6d2566c0f0beaaa273b2c 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 fetchMachine = Machine({
id: 'ho-type-quiz',
initial: 'idle',
context:{},
states: {
idle: {
on: {
START: 'structure',
},
},
structure: {
on: {
CONTINUE: {
target: 'freedom',
actions: assign((root, { value }) => ({
...root,
structure: value,
})),
},
},
},
freedom: {
on: {
CONTINUE: {
target: 'balance',
actions: assign((root, { value }) => ({
...root,
freedom: value,
})),
},
BACK: 'structure',
},
},
balance: {
on: {
CONTINUE: {
target: 'flexibility',
actions: assign((root, { value }) => ({
...root,
balance: value,
})),
},
BACK: 'freedom',
},
},
flexibility: {
on: {
CONTINUE: {
target: 'communication',
actions: assign((root, { value }) => ({
...root,
flexibility: value,
})),
},
BACK: 'balance',
},
},
communication: {
on: {
CONTINUE: {
target: 'coordination',
actions: assign((root, { value }) => ({
...root,
communication: value,
})),
},
BACK: 'flexibility',
},
},
coordination: {
on: {
CONTINUE: {
target: 'report',
actions: assign((root, { value }) => ({
...root,
coordination: value,
})),
},
BACK: 'communication',
},
},
report: {
entry: assign((root) => ({
...root,
report: {
work: (root.structure + root.freedom) / 2,
selfmanagement: (root.balance + root.flexibility) / 2,
team: (root.communication + root.coordination) / 2,
},
})),
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment