Last active
March 9, 2020 13:40
-
-
Save saschwarz/2ad7eeda381f43a4139c01df82d2a9ad to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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 dogPlay = Machine({ | |
id: 'dogplay', | |
initial: 'sleeping', | |
context: { | |
doorOpen: false, | |
}, | |
states: { | |
sleeping: { | |
on: { | |
LETS_PLAY: 'standing' | |
} | |
}, | |
standing: { | |
on: { | |
SIT: 'sitting' | |
} | |
}, | |
sitting: { | |
on: { | |
STAND: 'standing', | |
FREE: [ | |
{ | |
target: 'outside', | |
cond: 'doorIsOpen', | |
}, | |
{ target: 'standing' }], | |
}, | |
}, | |
outside: { | |
}, | |
}, | |
on: { | |
DOOR_OPEN: { | |
actions: [ | |
assign({doorOpen: _ => true}) | |
], | |
}, | |
DOOR_CLOSE: { | |
actions: [ | |
assign({doorOpen: _ => false}) | |
] | |
}, | |
} | |
}, | |
{ | |
guards: { | |
doorIsOpen: (context, event) => context.doorOpen | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment