Skip to content

Instantly share code, notes, and snippets.

@jbeast
Last active April 20, 2021 21:35
Show Gist options
  • Save jbeast/ab80c5d5e0d5f0129d99649b5d3968b7 to your computer and use it in GitHub Desktop.
Save jbeast/ab80c5d5e0d5f0129d99649b5d3968b7 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: "sampleMachine",
initial: "qc_ready",
context: {
},
on: {
FAIL_SAMPLE: "fail"
},
states: {
qc_ready: {
on: {
START_QC: "qc_in_progress"
}
},
qc_in_progress: {
on: {
QC_FAILED: "qc_fail",
QC_COMPLETE: {
target: "saving_qc_data_to_server",
actions: "assignQCMeasurement"
}
}
},
qc_fail: {
on: {
RETRY_QC: "qc_in_progress"
}
},
saving_qc_data_to_server: {
invoke: {
src: "saveQCData",
onDone: "qc_complete",
onError: "qc_fail"
}
},
qc_complete: {
on: {
RESTART: "qc_ready"
}
},
fail: {
done: true
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment