Skip to content

Instantly share code, notes, and snippets.

@samzmann
Last active October 28, 2020 10:04
Show Gist options
  • Save samzmann/c8e8bbb446fcb9494602a86a1ead7e1a to your computer and use it in GitHub Desktop.
Save samzmann/c8e8bbb446fcb9494602a86a1ead7e1a 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 evts = {
}
const fetchMachine = Machine({
id: 'Get Help Modal',
initial: 'articles',
context: {
errorMessage: null
},
states: {
articles: {
on: {
NAV_BOWL_ISSUE: 'articleBowlIssue',
NAV_CREDITS: 'articleCredits',
NAV_GENERAL_HELP: 'generalHelpForm',
}
},
articleBowlIssue: {
on: {
BACK: 'articles',
NEXT: 'reportSelectBowls'
}
},
articleCredits: {
on: {
BACK: 'articles',
},
},
articleCredits: {
on: {
BACK: 'articles',
},
},
generalHelpForm: {
on: {
BACK: 'articles',
}
},
reportSelectBowls: {
on: {
BACK: 'articleBowlIssue',
NEXT: 'reportForm'
}
},
reportForm: {
on: {
BACK: 'reportSelectBowls',
NEXT: 'reportSuccess',
ERROR: {
actions: assign({
errorMessage: (ctx,evt) => evt.errorMessage || 'Something went wrong'
}),
}
},
exit: assign({ errorMessage: () => null }),
},
reportSuccess: {
type: 'final'
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment