Skip to content

Instantly share code, notes, and snippets.

@sergiokopplin
Last active July 28, 2020 13:51
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 sergiokopplin/75d3390a3f869b1f779cbd5d707690f9 to your computer and use it in GitHub Desktop.
Save sergiokopplin/75d3390a3f869b1f779cbd5d707690f9 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'importer',
initial: 'idle',
states: {
idle: {
on: {
start: 'registration',
},
},
registration: {
id: 'registration',
initial: 'command',
states: {
command: {
initial: 'running',
states: {
running: {
invoke: {
id: 'sendJob',
src: 'sendJob',
onDone: {
target: 'success',
},
onError: {
target: '#failure',
},
},
},
success: {
on: {
done: '#searching-registration'
}
},
},
},
searching: {
id: 'searching-registration',
initial: 'running',
states: {
running: {
invoke: {
id: 'searchJob',
src: 'searchJob',
onDone: {
target: 'success',
},
onError: {
target: '#failure',
},
},
},
success: {
on: {
done: '#report-registration'
}
},
},
},
report: {
id: 'report-registration',
on: {
done: '#transaction'
}
},
},
},
transaction: {
id: 'transaction',
initial: 'command',
states: {
command: {
initial: 'running',
states: {
running: {
invoke: {
id: 'sendJob',
src: 'sendJob',
onDone: {
target: 'success',
},
onError: {
target: '#failure',
},
},
},
success: {
on: {
done: '#searching-transaction'
}
},
},
},
searching: {
id: 'searching-transaction',
initial: 'running',
states: {
running: {
invoke: {
id: 'searchJob',
src: 'searchJob',
onDone: {
target: 'success',
},
onError: {
target: '#failure',
},
},
},
success: {
on: {
done: '#report-transaction'
}
},
},
},
report: {
id: 'report-transaction',
on: {
done: '#report'
},
},
},
},
report: {
id: 'report',
type: 'final',
},
failure: {
type: 'final',
id: 'failure',
},
},
}, {
actions: {},
services: {
sendJob: () => ({}),
searchJob: () => ({}),
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment