Created
January 7, 2020 17:37
-
-
Save kevinfoerster/0e127c29e87ee0d05c5eeeb9eab649c6 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 fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'closed', | |
context: { | |
activeItem: null | |
}, | |
states: { | |
closed: { | |
on: { | |
OPEN: { | |
target: 'opening', | |
actions: ['openOverlay', 'setItem'] | |
} | |
} | |
}, | |
opening: { | |
on: { | |
"": { | |
target: "open", | |
} | |
} | |
}, | |
open: { | |
on: { | |
CLOSE: { | |
target: 'closing', | |
actions: ['closeOverlay', 'resetItem'] | |
}, | |
OPEN: { | |
target: '.', | |
actions: ['setItem'] | |
} | |
} | |
}, | |
closing: { | |
on: { | |
'': { | |
target: 'closed' | |
} | |
} | |
} | |
} | |
}, { | |
actions:{ | |
openOverlay: assign({ | |
}), | |
closeOverlay: assign({ | |
}), | |
resetItem: assign({ | |
activeItem: null | |
}), | |
setItem: assign({ | |
activeItem: (ctx, e) => e.item | |
}) | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment