Skip to content

Instantly share code, notes, and snippets.

@alexkreidler
Last active December 13, 2019 12:48
Show Gist options
  • Save alexkreidler/b076a457330088a780bef6c6cff97822 to your computer and use it in GitHub Desktop.
Save alexkreidler/b076a457330088a780bef6c6cff97822 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 cacheStates = {
initial: 'undetermined',
states: {
undetermined: {
on: {
DATA: 'determining'
}
},
determining: {
on: {
SUCCESS: 'determined',
FAILURE: 'uninitialized'
}
},
determined: {}
}
};
const processorMachine = Machine({
id: 'processor',
initial: 'uninitialized',
context: {
state: 0,
configuration: 0,
data: []
},
states: {
uninitialized: {
on: {
CONFIGURE_SUCCESS: 'configured',
CONFIGURE_FAILURE: 'uninitialized'
}
},
configured: {
on: {
DATA: 'has_state'
}
},
has_state: {
on: {
DONE: 'running'
},
...cacheStates
},
running: {
on: {
SUCCESS: 'done',
FAILURE: 'configured'
}
},
done: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment