Last active
September 30, 2019 03:09
-
-
Save mtoso/8a64c9dfb3cb0df696500b4b07608b77 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 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