Created
April 28, 2021 18:34
-
-
Save bradstewart/dd1c27b894b509c443cb6b076a456ffe to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
const operationMachine = Machine({ | |
id: 'op', | |
initial: 'ready', | |
context: { | |
loadPoolId: '', | |
blockTime: '', | |
exampleData: 0, | |
}, | |
states: { | |
ready: { | |
on: { | |
START: { target: 'applyingOnSite' }, | |
}, | |
}, | |
applyingOnSite: { | |
entry: ['runOnSiteMitigator',], | |
on: { | |
NEXT: { target: 'updatingOTAs', cond: 'isOnSiteComplete' }, | |
WAIT: { internal: true }, | |
}, | |
}, | |
updatingOTAs: { | |
entry: ['runOTAUpdater',], | |
on: { | |
NEXT: { target: 'applyingOTAs' }, | |
}, | |
}, | |
applyingOTAs: { | |
entry: ['runOTAMitigator'], | |
on: { | |
NEXT: [ | |
{ target: 'done', cond: 'isOTAMitigationComplete' }, | |
{ internal: false, | |
actions: [ | |
assign({ exampleData: (context, event) => context.exampleData++ }) | |
] }, | |
], | |
WAIT: { internal: true }, | |
}, | |
}, | |
done: { | |
type: 'final' | |
}, | |
}, | |
}, { | |
guards: { | |
hasData: (context, event) => { | |
return true | |
}, | |
isOnSiteComplete: (context, event) => { | |
console.log('isOnSiteComplete!') | |
return true | |
}, | |
isOTAMitigationComplete: (context, event) => { | |
console.log('isOTAMitigationComplete!', context.exampleData) | |
return context.exampleData > 3 | |
} | |
}, | |
actions: { | |
runOnSiteMitigator: (context, event) => { | |
console.log('runOnSiteMitigator!') | |
}, | |
runOTAUpdater: (context, event) => { | |
console.log('runOTAUpdater!') | |
}, | |
runOTAMitigator: (context, event) => { | |
console.log('runOTAMitigator!') | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment