Skip to content

Instantly share code, notes, and snippets.

@smikheiev
Last active August 26, 2020 10:01
Show Gist options
  • Save smikheiev/888f6d3c8778a5bb5dbcbaf4dc900ca1 to your computer and use it in GitHub Desktop.
Save smikheiev/888f6d3c8778a5bb5dbcbaf4dc900ca1 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 feedbackMachine = Machine({
id: 'therapistFeedbackContainer',
initial: 'init',
states: {
init: {
on: {
'': [
{
cond: 'isTodayMonday',
target: 'notApplicable',
},
{
cond: 'isNotInTreatment',
target: 'notApplicable',
},
{
target: 'waitingForChatOpened',
},
],
}
},
notApplicable: {},
waitingForChatOpened: {
on: {
CHAT_OPENED: 'waitingForTodayOpened',
},
},
waitingForTodayOpened: {
on: {
TODAY_TAB_OPENED: 'verifyTimeRequirements',
},
},
verifyTimeRequirements: {
invoke: {
src: 'verifyTimeRequirements',
onDone: 'active',
onError: 'waitingForChatOpened',
},
},
active: {
entry: 'showFeedback',
on: {
TODAY_TAB_LEFT: {
actions: 'hideFeedback',
target: 'init',
},
},
},
},
}, {
guards: {
isTodayMonday: () => false,
isNotInTreatment: () => false,
areTimeRequirementsVerified: () => true,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment