Last active
July 28, 2022 22:24
-
-
Save inphomercial/4fbbb26c71900e314e86e88a3ffc35e6 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 START = { | |
entry: ['moveToStart'], | |
on: { | |
MOVE_FORWARD: 'SELECT_ENVIRONMENT', | |
}, | |
} | |
const SELECT_ENVIRONMENT = { | |
entry: ['moveToEnvironment'], | |
on: { | |
MOVE_BACKWARD: 'START', | |
MOVE_FORWARD: 'SELECT_DATA', | |
} | |
} | |
const SELECT_DATA = { | |
on: { | |
MOVE_BACKWARD: 'SELECT_ENVIRONMENT', | |
MOVE_FORWARD: 'SELECT_SCENARIO', | |
}, | |
} | |
const SELECT_SCENARIO = { | |
on: { | |
MOVE_BACKWARD: 'SELECT_DATA', | |
MOVE_FORWARD: 'SELECT_OPTIONAL', | |
}, | |
} | |
const SELECT_OPTIONAL = { | |
on: { | |
MOVE_BACKWARD: 'SELECT_SCENARIO', | |
MOVE_FORWARD: 'FINISH', | |
}, | |
} | |
const FINISH = { | |
on: { | |
MOVE_BACKWARD: 'SELECT_OPTIONAL', | |
}, | |
} | |
const states = { | |
START, | |
SELECT_ENVIRONMENT, | |
SELECT_DATA, | |
SELECT_SCENARIO, | |
SELECT_OPTIONAL, | |
FINISH, | |
} | |
const initial = 'START' | |
const config = { | |
id: 'ConnectWizard', | |
initial, | |
context: { | |
config: {}, | |
}, | |
states, | |
strict: true, | |
} | |
const actionOptions = { | |
actions: { | |
moveToStart: (context, event) => { | |
console.log('moving to start!!!', context, event) | |
}, | |
// action implementation | |
moveToEnvironment: (context, event) => { | |
console.log('moving to environement!!!', context, event) | |
}, | |
}, | |
} | |
const machine = Machine(config, actionOptions) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment