Skip to content

Instantly share code, notes, and snippets.

@mtoso
Last active September 30, 2019 03:09
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 mtoso/8a64c9dfb3cb0df696500b4b07608b77 to your computer and use it in GitHub Desktop.
Save mtoso/8a64c9dfb3cb0df696500b4b07608b77 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 compilationMachine = Machine({
id: 'compilation',
initial: 'idle',
context: {
errors: []
},
states: {
idle: {
on: {
RUN: 'running'
}
},
running: {
on: {
DONE: 'done'
}
},
done: {
type: 'final'
}
}
});
const compilerMachine = Machine({
id: 'compiler',
initial: "initializing",
context: {
compilations: []
},
states: {
initializing: {
entry: assign({
compilations: (ctx, e) => {
return ctx.compilations.map(c => ({
...c,
ref: spawn(compilationMachine.withContext(c))
}));
},
}),
},
running: {},
completed: {}
},
on: {
"MARK.running": {
actions: ctx => {
ctx.compilations.forEach(c => c.ref.send("RUN"));
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment