Skip to content

Instantly share code, notes, and snippets.

@DogPawHat
Last active August 4, 2021 17:13
Show Gist options
  • Save DogPawHat/2a2caad956c342004456a841419bc3f5 to your computer and use it in GitHub Desktop.
Save DogPawHat/2a2caad956c342004456a841419bc3f5 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 fetchMachine = Machine({
id: 'questionsStream',
initial: 'notAnswering',
context: {
currentQuestion: ''
},
states: {
notAnswering: {
on: {
ANSWER_NEW_QUESTION: {
target: 'answering',
actions: assign({
currentQuestion: (ctx, event) => event.newQuestion
})
},
}
},
answering: {
on: {
ANSWER_NEW_QUESTION: {
target: 'answering',
actions: assign({
currentQuestion: (ctx, event) => event.newQuestion
})
},
CLOSE_CURRENT_QUESTION: {
target: 'notAnswering',
actions: assign({
currentQuestion: ''
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment