Skip to content

Instantly share code, notes, and snippets.

@laughnan
Created May 3, 2020 07:29
Show Gist options
  • Save laughnan/0d72ef66a37fc77e520e2e18393df548 to your computer and use it in GitHub Desktop.
Save laughnan/0d72ef66a37fc77e520e2e18393df548 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const ordersTooltipExperienceMachine = Machine({
id: "ordersTooltipExperienceV1",
initial: "init",
context: {
flowName: "ordersTooltipExperience",
},
states: {
init: {
exit: () => console.log('exiting'),
on: {
START_IF_ELIGIBLE: {
target: "determineEligibility",
},
}
},
determineEligibility: {
on: {
'': [
{ target: 'startedFlow', cond: 'canShow' },
{ target: 'init' },
],
}
},
startedFlow: {
initial: "seeMoreOrders",
states: {
seeMoreOrders: {
entry: ['onShow'],
on: {
DISMISS_TOOLTIP: {
target: "ordersMenuItem"
}
}
},
ordersMenuItem: {
on: {
DISMISS_TOOLTIP: {
target: "#ordersTooltipExperienceV1.completed"
}
}
},
},
},
completed: {
entry: ['onClose'],
},
}
}, {
actions: {
onClose: () => console.log('on close'),
onShow: () => console.log('on show'),
},
guards: {
canShow: () => true,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment