Created
June 12, 2020 06:32
-
-
Save epan/8d36362c6b2997f94c64f26b060eb772 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 addressManagerMachine = Machine({ | |
id: 'addressManager', | |
context: { prompts: [] }, | |
initial: 'closed', | |
states: { | |
closed: { | |
on: { | |
CLICK: 'addressList' | |
} | |
}, | |
addressList: { | |
initial: 'list', | |
states: { | |
list: { | |
on: { | |
// GET PromptList | |
SELECT: [ | |
{ | |
target: '#addressManager.consumerPrompt', | |
cond: 'hasPrompts' | |
}, | |
{ | |
target: '#addressManager.closed', | |
} | |
], | |
// GET PromptList | |
EDIT: [ | |
{ | |
target: '#addressManager.consumerPrompt', | |
cond: 'hasPrompts' | |
}, | |
{ | |
target: '#addressManager.editAddressForm', | |
} | |
], | |
SEARCH: 'searchResults', | |
} | |
}, | |
searchResults: { | |
on: { | |
// GET PromptList | |
SELECT: [ | |
{ | |
target: '#addressManager.consumerPrompt', | |
cond: 'hasPrompts' | |
}, | |
{ | |
target: '#addressManager.editAddressForm', | |
} | |
], | |
} | |
} | |
}, | |
}, | |
editAddressForm: { | |
on: { | |
CANCEL: 'addressList', | |
SAVE: 'addressList', | |
ADJUST_PIN: 'changePinLocationForm' | |
} | |
}, | |
changePinLocationForm: { | |
on: { | |
CANCEL: 'editAddressForm', | |
SAVE: 'editAddressForm' | |
} | |
}, | |
consumerPrompt: { | |
on: { | |
AGREE: 'changePinLocationForm', | |
// TODO: FIX REJECT | |
REJECT: 'closed' | |
} | |
}, | |
loading: {}, | |
}, | |
on: { | |
CLOSE: '.closed' | |
} | |
}, { | |
guards: { | |
hasPrompts: context => context.prompts.length > 0 | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment