Created
August 24, 2020 15:38
-
-
Save BrianCortes/2cefb7bf9336d408744d24a4cba82fe5 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 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