Last active
September 12, 2019 05:30
-
-
Save victor36max/7a1b3c08a172b656f1249e8010c34538 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 machine = Machine({ | |
id: 'collapsible', | |
initial: 'closed', | |
states: { | |
closed: { | |
on: { | |
OPEN: { | |
target: 'opening', | |
actions: 'closedToOpeningAnimation', | |
}, | |
}, | |
}, | |
opening: { | |
invoke: { | |
src: 'openingAnimation', | |
onDone: 'opened', | |
}, | |
on: { | |
CLOSE: 'closing', | |
}, | |
}, | |
opened: { | |
entry: 'openedAnimation', | |
on: { | |
CLOSE: { | |
target: 'closing', | |
actions: 'openedToClosingAnimation', | |
}, | |
}, | |
}, | |
closing: { | |
invoke: { | |
src: 'closingAnimation', | |
onDone: 'closed', | |
}, | |
on: { | |
OPEN: 'opening', | |
}, | |
}, | |
}, | |
}, { | |
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