Skip to content

Instantly share code, notes, and snippets.

@isaacplmann
Last active July 17, 2019 01:39
Show Gist options
  • Save isaacplmann/b2bde884731c24501a621895d89ebe7d to your computer and use it in GitHub Desktop.
Save isaacplmann/b2bde884731c24501a621895d89ebe7d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const matchingMachine = Machine(
{
id: 'matching',
context: { choiceOneIndex: undefined, choiceTwoIndex: undefined },
initial: 'answering',
states: {
answering: {
type: 'parallel',
states: {
choiceOne: {
initial: 'unselected',
states: {
unselected: {
on: { SELECT_ONE: 'selected' }
},
selected: {
onEntry: assign({
choiceOneIndex: (ctx, event) => event.selectedIndex
}),
type: 'final'
}
}
},
choiceTwo: {
initial: 'unselected',
states: {
unselected: {
on: { SELECT_TWO: 'selected' }
},
selected: {
onEntry: assign({
choiceTwoIndex: (ctx, event) => event.selectedIndex
}),
type: 'final'
}
}
}
},
onEntry: assign({
choiceOneIndex: () => undefined,
choiceTwoIndex: () => undefined
}),
onDone: 'submitted',
},
submitted: {
on: {
CLEAR: 'answering'
}
}
}
},
{}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment