Last active
May 22, 2020 22:37
-
-
Save pieh/0542e7e00509592d395c837416981b22 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 fetchMachine = Machine({ | |
id: 'coordinator', | |
initial: 'afterInitialWebpack', | |
context: { | |
webpackNeedsResuming: false, | |
queriesNeedReunning: false | |
}, | |
states: { | |
bootstrap: { | |
initial: 'init', | |
states: { | |
init: { | |
on: { | |
START_QUERY_RUNNING: 'initialQueryRunning' | |
} | |
}, | |
initialQueryRunning: { | |
onDone: 'initialWebpack', | |
}, | |
initialWebpack: { | |
onDone: { | |
target: '#coordinator.afterInitialWebpack.writeOutPageData', | |
actions: ['suspendWebpack'] | |
}, | |
}, | |
} | |
}, | |
afterInitialWebpack: { | |
initial: `writeOutPageData`, | |
on: { | |
WEBPACK_INVALID: { | |
actions: [`enqueueWebpack`] | |
}, | |
START_QUERY_RUNNING: { | |
actions: [`enqueueQueueRunning`] | |
} | |
}, | |
states: { | |
writeOutPageData: { | |
onDone: "idle" | |
}, | |
idle: { | |
on: { | |
START_QUERY_RUNNING: 'queryRunning', | |
WEBPACK_INVALID: `webackRecompile` | |
} | |
}, | |
queryRunning: { | |
entry: [`clearQueryQueue`], | |
on: { | |
MODULE_ADDED_OR_REMOVED: { | |
actions: [`enqueueWebpack`] | |
} | |
}, | |
onDone: [ | |
{ | |
cond: `queriesNeedRunning`, | |
target: `queryRunning`, | |
}, | |
{ | |
cond: 'webpackNeedsResuming', | |
target: 'webackRecompile' | |
}, | |
{ | |
target: `writeOutPageData` | |
} | |
], | |
}, | |
webackRecompile: { | |
entry: [`clearWebpackQueue`, `resumeWebpack`], | |
exit: [`suspendWebpack`], | |
onDone: [ | |
{ | |
cond: `queriesNeedRunning`, | |
target: `queryRunning`, | |
}, | |
{ | |
target: `writeOutPageData` | |
} | |
] | |
}, | |
}, | |
} | |
} | |
}, { | |
actions: { | |
enqueueWebpack: assign({ | |
webpackNeedsResuming: true | |
}), | |
clearWebpackQueue: assign({ | |
webpackNeedsResuming: false | |
}), | |
enqueueQueueRunning: assign({ | |
queriesNeedReunning: true | |
}), | |
clearQueryQueue: assign({ | |
queriesNeedReunning: false | |
}), | |
}, | |
guards: { | |
webpackNeedsResuming: context => context.webpackNeedsResuming, | |
queriesNeedRunning: context => context.queriesNeedReunning | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment