Skip to content

Instantly share code, notes, and snippets.

@BrianCortes
Created August 24, 2020 15:38
Show Gist options
  • Save BrianCortes/2cefb7bf9336d408744d24a4cba82fe5 to your computer and use it in GitHub Desktop.
Save BrianCortes/2cefb7bf9336d408744d24a4cba82fe5 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 changeStep = assign({
currentStep: (context, event) => {
return context.currentStep + 1;
}
});
const multiStepMachine = Machine(
{
id: 'MultiSteps',
initial: 'showing',
context: {
steps: [0, 1, 2],
currentStep: 0
},
states: {
showing: {
on: {
NEXT: {
target: '',
actions: ['changeStep']
},
SKIP: {
target: '',
actions: ['changeStep']
},
END: 'finish'
}
},
finish: {
type: 'final'
}
}
},
{
actions: {
changeStep,
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment