Last active
December 13, 2019 12:48
-
-
Save alexkreidler/b076a457330088a780bef6c6cff97822 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 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