Skip to content

Instantly share code, notes, and snippets.

@joaom182
Last active November 9, 2021 22:38
Show Gist options
  • Save joaom182/8c9d161595ab93dabd57a45e076c7e8b to your computer and use it in GitHub Desktop.
Save joaom182/8c9d161595ab93dabd57a45e076c7e8b 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: 'entity-information',
initial: 'get_entity_ownership',
states: {
get_entity_ownership: {
exit: ['assignUpstreamEntities'],
on: {
NEXT: [
{
target: 'entity_authorized_signers',
cond: 'currentEntityIsRoot'
},
{
target: 'entity_information_owning',
cond: 'isLastEntity'
},
{
actions: ['assignNextEntity'],
target: 'get_entity_ownership'
}
],
BACK: [
{
target: 'owning_parts_down_stream',
cond: 'isLastStateOwning'
},
{
target: 'entity_authorized_signers',
cond: 'previousEntityIsRoot',
actions: 'assignPreviousEntity'
},
{
target: 'get_entity_ownership',
actions: ['assignPreviousEntity']
}
],
EVENT_DATA: {}
}
},
['entity_authorized_signers']: {
on: {
NEXT: [
{
target: 'entity_information_owning',
cond: 'hasOnlyOneEntity'
},
{
target: 'entity_information_owning',
cond: 'isLastEntity'
},
{
target: 'get_entity_ownership',
actions: ['assignNextEntity']
}
],
BACK: {
target: 'get_entity_ownership'
}
}
},
entity_information_owning: {
on: {
NEXT: [
{
target: 'owning_parts_down_stream',
cond: 'isOwning'
},
{
target: 'final'
}
],
BACK: [
{
target: 'entity_authorized_signers',
cond: 'hasOnlyOneEntity'
},
{
target: 'get_entity_ownership'
}
]
}
},
['owning_parts_down_stream']: {
exit: ['assignUpstreamEntities'],
on: {
NEXT: [
{
target: 'final',
actions: ['assignNextEntity'],
cond: 'IsNoDownstreamEntities'
},
{
actions: ['assignDownstreamEntities', 'assignInitialDownstreamEntity'],
target: 'get_entity_ownership_down_stream'
}
],
BACK: {
target: 'entity_information_owning'
},
EVENT_DATA: {}
}
},
get_entity_ownership_down_stream: {
exit: ['assignDownstreamEntities'],
on: {
NEXT: [
{
target: 'final',
cond: 'isLastDownstreamEntity'
},
{
actions: ['assignNextDownstreamEntity'],
target: 'get_entity_ownership_down_stream'
}
],
BACK: [
{
target: 'owning_parts_down_stream',
cond: 'isLastStateOwning'
},
{
target: 'owning_parts_down_stream',
cond: 'isCurrentDownstreamEntityFirst'
},
{
target: 'get_entity_ownership_down_stream',
actions: ['assignPreviousDownstreamEntity']
}
],
EVENT_DATA: {}
}
},
['final']: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment