Last active
August 26, 2020 10:01
-
-
Save smikheiev/888f6d3c8778a5bb5dbcbaf4dc900ca1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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