Created
October 10, 2019 14:31
-
-
Save tiagonevestia/31fcb7fabf3987a7e6f2ac549fe32f0d 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
const fetchMachine = Machine({ | |
id: 'post-screen', | |
initial: 'ready', | |
context: { | |
text: '', | |
}, | |
states: { | |
ready: { | |
type: 'paralell', | |
on: { | |
INPUT_TEXT: { | |
actions: 'cacheText', | |
target: 'ready.text.noError' | |
}, | |
SUBMIT: [ | |
{ | |
target: 'ready.text.error.empty', | |
cond: 'isNoText', | |
}, | |
{ | |
target: 'waitingResponse', | |
}, | |
], | |
}, | |
states: { | |
text: { | |
initial: 'error', | |
states: { | |
noError: {}, | |
error: { | |
initial: 'empty', | |
states: { | |
empty: {}, | |
}, | |
onEntry: 'focusTextInput', | |
}, | |
}, | |
} | |
} | |
}, | |
waitingResponse: { | |
on: { | |
CANCEL: 'ready', | |
}, | |
invoke: { | |
src: 'requestPostCreate', | |
}, | |
onDone: { | |
actions: 'onSuccess', | |
}, | |
onError: [ | |
{ | |
cond: 'isInternalServerErr', | |
target: 'ready.authService.error.internal', | |
}, | |
// { | |
// cond: "isIncorrectPassword", | |
// target: "ready.password.error.incorrect" | |
// }, | |
// { | |
// cond: "isNoResponse", | |
// target: "ready.authService.error.communication" | |
// }, | |
// { | |
// cond: "isInternalServerErr", | |
// target: "ready.authService.error.internal" | |
// } | |
], | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment