Skip to content

Instantly share code, notes, and snippets.

@faberyx
Last active September 30, 2019 13:24
Show Gist options
  • Save faberyx/e825b9486fe3aa7f849c184046563d55 to your computer and use it in GitHub Desktop.
Save faberyx/e825b9486fe3aa7f849c184046563d55 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 flowMachine = Machine({
id: 'flow',
initial: 'component_list',
context: {
components: ['country', 'phone_number']
},
states: {
component_list:{
initial: 'step_country',
states: {
step_country: {
data: 'country, phone_number',
on: {
NEXT: 'step_operator',
}
},
step_operator: {
on: {
NEXT: 'step_denomination',
}
},
step_denomination: {
on: {
NEXT: 'step_authorization',
}
},
step_authorization: {
on: {
NEXT: 'step_payment',
}
},
step_payment: {
on: {
NEXT: 'step_country',
}
},
}
},
summary:{
states:{
empty: 'empty',
summary: 'summary'
}
}
}
},{
actions: {
component_list: (context, event) => {
switch (event.type) {
case 'NEXT':
console.log(context,event)
break;
default:
context.method = 'cash';
break;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment