Created
December 30, 2019 16:56
-
-
Save h-jennings/0b9ace0102d1cef21f89c76bfa4bcadc 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
const dataCollectionStates = { | |
id: 'dataCollectionStates', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
CHANGE: { | |
target: 'idle', | |
actions: ['updateValue'], | |
}, | |
}, | |
}, | |
}, | |
}; | |
const Caffeinator = new Machine({ | |
id: 'Caffeinator', | |
initial: 'idle', | |
context: { | |
cupAmount: 1, | |
}, | |
states: { | |
idle: { | |
on: { | |
START: { | |
target: 'start', | |
}, | |
}, | |
}, | |
start: { | |
on: { | |
MAKE_COFFEE: { | |
target: 'Grind_Beans', | |
}, | |
}, | |
...dataCollectionStates, | |
}, | |
Grind_Beans: { | |
on: { | |
RESET: 'idle', | |
NEXT: { | |
target: 'Add_Water', | |
}, | |
PREV: 'start', | |
}, | |
}, | |
Add_Water: { | |
on: { | |
RESET: 'idle', | |
NEXT: { | |
target: 'Stir', | |
}, | |
PREV: 'Grind_Beans', | |
}, | |
}, | |
Stir: { | |
entry: 'createTimer', | |
on: { | |
RESET: 'idle', | |
NEXT: { | |
target: 'Add_Remaining_Water', | |
}, | |
PREV: 'Add_Water', | |
}, | |
}, | |
Add_Remaining_Water: { | |
on: { | |
RESET: 'idle', | |
NEXT: { | |
target: 'Wait', | |
}, | |
PREV: 'Stir', | |
}, | |
}, | |
Wait: { | |
entry: 'createTimer', | |
on: { | |
RESET: 'idle', | |
NEXT: 'Finished', | |
PREV: 'Add_Remaining_Water', | |
}, | |
}, | |
Finished: { | |
type: 'final', | |
on: { | |
RESET: 'idle', | |
PREV: 'Wait', | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment