Skip to content

Instantly share code, notes, and snippets.

@spiffytech
Last active December 23, 2019 12:31
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 spiffytech/97d864cfa40eb2f600bef6f1b4925e3e to your computer and use it in GitHub Desktop.
Save spiffytech/97d864cfa40eb2f600bef6f1b4925e3e 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 machine = Machine({
initial: 'loading',
context: {
value: 0
},
invoke: {
src: 'onload'
},
on: {
loaded: {
target: 'loaded',
internal: true,
actions: assign((context) => ({value: context.value + 1}))
}
},
states: {
loading: {},
loaded: {}
}
}, {
services: {
onload: () => (fireEvent) => {
setTimeout(() => fireEvent('loaded'), 1000)
}
}
});
const service = interpret(machine);
service.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment