Last active
July 15, 2020 07:05
-
-
Save baeharam/8e282b20b01907eb00677c27fd9e1164 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
const INACTIVE = '비활성화'; | |
const ACTIVE = '활성화'; | |
const DELETE_PENDING = '삭제로딩'; | |
const DELETE_SUCCESS = '삭제성공'; | |
const DELETE_FAILURE = '삭제실패'; | |
// Events | |
const TYPE = '입력'; | |
const DELETE = '삭제'; | |
const isEqualToProductName = () => {} | |
const deleteProduct = () => {} | |
const deleteProductMachine = Machine( | |
{ | |
id: 'deleteProductMachine', | |
initial: INACTIVE, | |
context: { | |
canDelete: false, | |
product: null, | |
}, | |
states: { | |
[INACTIVE]: { | |
on: { | |
[TYPE]: [ | |
{ | |
cond: isEqualToProductName, | |
target: ACTIVE, | |
}, | |
], | |
}, | |
}, | |
[ACTIVE]: { | |
on: { | |
[DELETE]: DELETE_PENDING, | |
[TYPE]: INACTIVE, | |
}, | |
}, | |
[DELETE_PENDING]: { | |
invoke: { | |
id: 'deleteProduct', | |
src: 'deleteProduct', | |
onDone: DELETE_SUCCESS, | |
onError: DELETE_FAILURE, | |
}, | |
}, | |
[DELETE_SUCCESS]: {}, | |
[DELETE_FAILURE]: { | |
after: { | |
1500: ACTIVE, | |
}, | |
}, | |
}, | |
}, | |
{ | |
guards: { | |
isEqualToProductName, | |
}, | |
}, | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment