Last active
June 18, 2020 17:24
-
-
Save epan/8786d11d137094e8c09dda078a8874e1 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
// V1.1 basic with new vs existing address flow states | |
const addressManagerMachine = Machine({ | |
id: 'addressManager', | |
initial: 'closed', | |
states: { | |
closed: { | |
on: { | |
CLICK: 'addressList' | |
} | |
}, | |
addressList: { | |
initial: 'list', | |
states: { | |
list: { | |
on: { | |
SELECT: '#addressManager.setAddressAsDefault', | |
EDIT: '#addressManager.editExistingAddress', | |
SEARCH: 'searchResults', | |
} | |
}, | |
searchResults: { | |
on: { | |
SELECT: '#addressManager.editNewAddress', | |
} | |
} | |
}, | |
}, | |
editExistingAddress: { | |
on: { | |
CANCEL: 'addressList', | |
SAVE: 'addressList', | |
ADJUST_PIN: 'changeExistingPinLocation' | |
} | |
}, | |
editNewAddress: { | |
on: { | |
CANCEL: 'addressList', | |
SAVE: 'setAddressAsDefault', | |
ADJUST_PIN: 'changeNewPinLocation' | |
} | |
}, | |
setAddressAsDefault: { | |
on: { | |
SUCCESS: 'closed', | |
FAIL: 'addressList' | |
} | |
}, | |
changeExistingPinLocation: { | |
on: { | |
CANCEL: 'editExistingAddress', | |
SAVE: 'editExistingAddress' | |
} | |
}, | |
changeNewPinLocation: { | |
on: { | |
CANCEL: 'editNewAddress', | |
SAVE: 'editNewAddress' | |
} | |
}, | |
loading: {}, | |
}, | |
on: { | |
CLOSE: '.closed' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment