Skip to content

Instantly share code, notes, and snippets.

@georgefeast
Last active December 2, 2019 03:46
Show Gist options
  • Save georgefeast/bc7f0574d6d02713de93563d1a88012b to your computer and use it in GitHub Desktop.
Save georgefeast/bc7f0574d6d02713de93563d1a88012b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const setProgressTo = p => assign({
progress: () => p,
})
const fetchMachine = Machine({
id: 'fetch',
context: {
numberShares: 0,
progress: 0
},
initial: 'requestAllocation',
states: {
requestAllocation: {
on: {
NEXT: {
target: 'bankAccount',
actions: assign({
numberShares: (_, event) => event.value,
}),
}
},
entry: setProgressTo(0),
},
bankAccount: {
entry: setProgressTo(50),
on: {
NEXT: {
target: 'confirmation',
},
BACK: {
target: 'requestAllocation',
},
}
},
confirmation: {
entry: setProgressTo(100),
type: "final"
}
}
}, {
guards: {
isSetupComplete: () => true
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment