Created
October 23, 2019 10:09
-
-
Save tamebadger/0c05b669d5443adec4d5a8dfdd597735 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 isUndefined = (x) => typeof x === 'undefined'; | |
const flightOpen = ({ flight }) => !isUndefined(flight); | |
const flightClosed = ({ flight }) => !!isUndefined(flight); | |
const fetchMachine = Machine({ | |
id: 'flight', | |
context: { flight: undefined }, | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'open', cond: flightOpen }, | |
{ target: 'closed', cond: flightClosed } | |
] | |
} | |
}, | |
open: { | |
on: { CLOSE: { target: 'closed', actions: 'closeFlight' } }, | |
entry: ['notifyActive'] | |
}, | |
closed: { | |
on: { OPEN: { target: 'open', actions: 'openFlight' } }, | |
entry: ['notifyInactive'] | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment