Skip to content

Instantly share code, notes, and snippets.

@ascorbic
Created February 19, 2020 16:36
Show Gist options
  • Save ascorbic/3b0d514019a15549255571f5c9b5a0a0 to your computer and use it in GitHub Desktop.
Save ascorbic/3b0d514019a15549255571f5c9b5a0a0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: `inc-build`,
initial: `fetchingEnvironment`,
context: {
refreshBody: null,
},
states: {
fetchingEnvironment: {
invoke: {
// src: (_context, _event) => controller.fetchEnvironment(),
onDone: `fetchingBuildId`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
fetchingBuildId: {
invoke: {
// src: (_context, _event) => controller.fetchBuildId(),
onDone: `cloning`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
cloning: {
invoke: {
// src: (_context, _event) => controller.clone(),
onDone: `installing`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
installing: {
invoke: {
// src: (_context, _event) => controller.install(),
onDone: `pollingForWork`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
clearCache: {
invoke: {
// src: (_context, _event) => controller.clearCache(),
onDone: `building`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
pullingSource: {
invoke: {
// src: (_context, _event) => controller.pull(),
onDone: `ensuringLatestDependencies`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
ensuringLatestDependencies: {
invoke: {
// src: (_context, _event) => controller.ensureLatestDependencies(),
onDone: `clearCache`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
pollingForWork: {
invoke: {
// src: async (_context, _event) => controller.pollForWork(),
onDone: {
target: `running`,
// actions: send(() => {
// const event = controller.getBuildEvent()
// return { type: event || `POLLING` }
// }),
},
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
running: {
on: {
POLLING: `pollingForWork`,
REBUILD: `stopping`,
SOURCE_UPDATE: `pullingSource`,
DATA_UPDATE: {
target: `refreshing`,
// actions: assign({
// // store the request body in the context, to be read from the refreshing state
// refreshBody: (_context, event) => event.payload,
// }),
},
},
},
building: {
invoke: {
// src: async () => {
// await controller.incBuild()
// },
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
on: {
DONE: {
target: `uploading`,
},
},
},
refreshing: {
invoke: {
// src: async context => {
// await controller.refresh(context.refreshBody)
// },
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
on: {
DONE: `uploading`,
},
},
uploading: {
invoke: {
// src: (_context, event) => {
// const dirPath = get(event, `path`)
// const deletedFiles = get(event, `deletedFiles`)
// return controller.incrementalUpload({ dir: dirPath, deletedFiles })
// },
onDone: `pollingForWork`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
stopping: {
invoke: {
// src: (_context, _event) => controller.stop(),
onDone: `ensuringLatestDependencies`,
onError: {
// actions: (_, event) => controller.logError(event),
target: `pollingForWork`,
},
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment