Skip to content

Instantly share code, notes, and snippets.

@joaom182
Created November 10, 2021 13:59
Show Gist options
  • Save joaom182/133f8f5d4e75257877c0579c707c73bb to your computer and use it in GitHub Desktop.
Save joaom182/133f8f5d4e75257877c0579c707c73bb 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: 'entity_authorized_signers',
entry: ['assignUpstreamEntities', 'assignInitialEntity'],
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_down_stream'
}
],
BACK: [
{
target: 'owning_parts_down_stream',
cond: 'isLastStateOwning'
},
{
target: 'disclosures_loop',
cond: 'currentEntityIsRoot'
},
{
target: 'entity_authorized_signers',
cond: 'previousEntityIsRoot',
actions: 'assignPreviousEntity'
},
{
target: 'get_entity_ownership',
actions: ['assignPreviousEntity']
}
]
}
},
'disclosures_loop': {},
'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'
}
}
},
'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']
}
]
}
},
'final': {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment