Skip to content

Instantly share code, notes, and snippets.

@kdgerona
Last active June 11, 2021 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdgerona/a9ff51fe479f646fa457f26b8af51768 to your computer and use it in GitHub Desktop.
Save kdgerona/a9ff51fe479f646fa457f26b8af51768 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const context = {
config: {
max_attempts: 5
},
data: {
fields: {},
entity_id: '',
entity: 'users',
isSaveAndClose: false,
attempts: 0
}
}
const config = {
id: 'full-dialog-contents-container',
initial: 'load_apps',
context,
states: {
check_attempts: {
after: {
3000: [
{
cond: 'isMaxAttemptReached',
target: 'done'
},
{
target: 'load_apps'
}
]
}
},
load_apps: {
entry: ['getContentApplications'],
on: {
SUCCESS: {
target: 'pristine'
},
FAILED: {
target: 'failed'
}
}
},
pristine: {
on: {
INPUT: {
target: 'dirty'
}
}
},
dirty: {
invoke: [],
on: {
CHANGE: {
target: 'dirty'
},
SAVE: {
target: 'submitting'
},
SAVE_AND_CLOSE: {
actions: ['activateSaveAndClose'],
target: 'submitting'
}
}
},
submitting: {
entry: ['submitEntity'],
on: {
SUCCESS: [
{
cond: 'isSaveAndClose',
target: 'done'
},
{
target: 'pristine'
}
],
FAILED: {
actions: ['sendErrorMessageToParent'],
target: 'failed'
}
}
},
done: {
type: 'final'
},
failed: {
after: {
3000: {
actions: ['incrementLoadApps'],
target: 'check_attempts'
}
}
},
timeout: {}
}
}
const implementations = {
actions: {}
}
const machine = Machine(config, implementations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment