Created
September 9, 2019 08:05
-
-
Save victor36max/7431727e5e8c7de6f7fc012129d80a8d 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: 'collapsible', | |
initial: 'closed', | |
states: { | |
closed: { | |
on: { | |
OPEN: { | |
target: 'opening', | |
actions: 'closedToOpeningAnimation', | |
}, | |
}, | |
}, | |
opening: { | |
invoke: { | |
src: 'openingAnimation', | |
onDone: 'opened', | |
}, | |
}, | |
opened: { | |
entry: 'openedAnimation', | |
on: { | |
CLOSE: { | |
target: 'closing', | |
actions: 'openedToClosingAnimation', | |
}, | |
}, | |
}, | |
closing: { | |
invoke: { | |
src: 'closingAnimation', | |
onDone: 'closed', | |
}, | |
}, | |
}, | |
}, { | |
services: { | |
openingAnimation: () => new Promise(resolve => setTimeout(resolve, 2000)), | |
closingAnimation: () => new Promise(resolve => setTimeout(resolve, 2000)), | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment