Created
September 21, 2020 01:36
-
-
Save jesstelford/4c8d594127f94be1f04ee6203961d83a 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const modalStates = { | |
initial: 'edit', | |
states: { | |
edit: { | |
on: { | |
SAVE: 'saving', | |
CLOSE: 'close' | |
} | |
}, | |
saving: { | |
on: { | |
ERROR: 'edit', | |
SUCCESS: 'success' | |
} | |
}, | |
success: { | |
type: 'final' | |
}, | |
close: { | |
type: 'final' | |
} | |
}, | |
// onDone: 'history' | |
}; | |
const checkoutStates = { | |
id: 'checkout', | |
type: 'parallel', | |
states: { | |
address: { | |
id: 'address', | |
initial: 'firstTime', | |
states: { | |
firstTime: { | |
initial: 'edit', | |
states: { | |
edit: { | |
on: { | |
SAVE: 'saving', | |
} | |
}, | |
saving: { | |
on: { | |
ERROR: 'edit', | |
SUCCESS: 'success' | |
} | |
}, | |
success: { | |
type: 'final' | |
} | |
}, | |
onDone: 'selected', | |
}, | |
selected: { | |
on: { CHANGE: 'list' } | |
}, | |
list: { | |
on: { | |
CLOSE: 'selected', | |
//ADD: 'parent.parent.addressModal' | |
//EDIT: 'parent.parent.addressModal' | |
} | |
}, | |
} | |
}, | |
paymentMethod: { | |
id: 'paymentMethod', | |
initial: 'firstTime', | |
states: { | |
firstTime: { | |
initial: 'edit', | |
states: { | |
edit: { | |
on: { | |
SAVE: 'saving', | |
} | |
}, | |
saving: { | |
on: { | |
ERROR: 'edit', | |
SUCCESS: 'success' | |
} | |
}, | |
success: { | |
type: 'final' | |
} | |
}, | |
onDone: 'selected', | |
}, | |
selected: { | |
on: { CHANGE: 'list' } | |
}, | |
list: { | |
on: { | |
CLOSE: 'selected', | |
//ADD: 'parent.parent.addressModal' | |
//EDIT: 'parent.parent.addressModal' | |
} | |
}, | |
} | |
}, | |
} | |
} | |
const checkoutMachine = Machine({ | |
id: 'checkout', | |
initial: 'checkout', | |
states: { | |
checkout: { | |
...checkoutStates | |
}, | |
addressModal: { | |
...modalStates | |
}, | |
paymentMethodModal: { | |
...modalStates | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment