Last active
January 24, 2021 19:34
-
-
Save pangratz/6a81c3860b6292baab6e14da952744b0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 fetchMachine = Machine({ | |
id: 'house-of-cards', | |
initial: 'overview', | |
context: { | |
cards: null, | |
currentCardIndex: null | |
}, | |
states: { | |
overview: { | |
on: { | |
START_QUIZ: 'quiz' | |
} | |
}, | |
quiz: { | |
initial: 'unstarted', | |
on: { | |
CANCEL_QUIZ: 'overview' | |
}, | |
states: { | |
unstarted: { | |
on: { | |
START: { | |
target: 'started', | |
actions: ['resetCurrentCardIndex'] | |
} | |
} | |
}, | |
started: { | |
on: { | |
NEXT: [{ | |
target: 'finished', | |
cond: 'isLast' | |
}, { | |
target: 'started', | |
actions: ['incrementCurrentCardIndex'] | |
}], | |
PREV: [{ | |
target: 'unstarted', | |
cond: 'isFirst' | |
}, { | |
target: 'started', | |
actions: ['decrementCurrentCardIndex'] | |
}] | |
} | |
}, | |
finished: { | |
on: { | |
RESTART: { | |
target: 'unstarted' | |
} | |
} | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment