Last active
September 13, 2019 22:20
-
-
Save jeremy-green/04ffd9e1d431fc1074ee5a91fc22a046 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
new Machine( | |
{ | |
id: 'weather', | |
initial: 'boot', | |
states: { | |
boot: { | |
on: { | |
PRECIPITATION: { target: 'precipitation', actions: ['notify'] }, | |
NO_PRECIPITATION: { target: 'no_precipitation', actions: ['notify'] }, | |
REJECTED: { target: 'boot', actions: ['rejected'] }, | |
}, | |
}, | |
no_precipitation: { | |
on: { | |
PRECIPITATION: { target: 'precipitation', actions: ['notify'] }, | |
REJECTED: { target: 'no_precipitation', actions: ['rejected'] }, | |
}, | |
}, | |
precipitation: { | |
on: { | |
NO_PRECIPITATION: { target: 'no_precipitation', actions: ['notify'] }, | |
REJECTED: { target: 'precipitation', actions: ['rejected'] }, | |
}, | |
}, | |
}, | |
}, | |
{ | |
actions: { | |
notify(context, { status, currently }) { | |
console.log('precipitation', { status, currently }); | |
}, | |
rejected(context, event) { | |
console.log('rejected', context, event); | |
}, | |
}, | |
}, | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment