Skip to content

Instantly share code, notes, and snippets.

@smikheiev
Last active August 22, 2020 13:54
Show Gist options
  • Save smikheiev/85575f8693c4c827d52205780f7f3664 to your computer and use it in GitHub Desktop.
Save smikheiev/85575f8693c4c827d52205780f7f3664 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: {
on: {
'': [
{
cond: 'areTimeRequirementsVerified',
target: 'active',
},
{
target: '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