Last active
October 4, 2021 23:40
-
-
Save parties/1229c93d90c159006d206e2f75da02ad to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const dataEditorMachine = Machine({ | |
id: 'data_editor', | |
initial: 'idle', | |
context: { | |
retries: 0, | |
generationSource: '', | |
}, | |
states: { | |
idle: { | |
id: 'idle', | |
on: { | |
CHOOSE_FUNCTION: { | |
target: 'validate', | |
actions: assign({ | |
generationSource: 'function', | |
}) | |
}, | |
CHOOSE_KIND: { | |
target: 'validate', | |
actions: assign({ | |
generationSource: 'kind', | |
}) | |
}, | |
CHOOSE_DEFAULT: { | |
target: 'validate', | |
actions: assign({ | |
generationSource: 'default', | |
}) | |
}, | |
} | |
}, | |
validate: { | |
id: 'validate', | |
initial: 'idle', | |
states: { | |
// a state for waiting for the user | |
// to choose where to go next | |
idle: { | |
on: { | |
SKIP_WARNING: { | |
target: '#generate' | |
} | |
} | |
}, | |
levels: { | |
on: { | |
SUCCESS: 'evidence', | |
FAILURE: { | |
target: '#idle', | |
actions: assign({ | |
error: 'Too many levels' | |
}) | |
}, | |
} | |
}, | |
evidence: { | |
on: { | |
SUCCESS: 'connectedness', | |
FAILURE: { | |
target: 'idle' | |
} | |
} | |
}, | |
connectedness: {}, | |
} | |
}, | |
generate: { | |
id: 'generate', | |
on: { | |
ERROR: 'generate', | |
SUCCESS: 'modify' | |
} | |
}, | |
modify: {}, | |
loading: { | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure' | |
} | |
}, | |
success: { | |
type: 'final' | |
}, | |
failure: { | |
on: { | |
RETRY: { | |
target: 'loading', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment