Created
October 16, 2019 19:52
-
-
Save tivac/f8ec83acba677f5e88bfeda5e7ab39e3 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({ | |
initial: 'run', | |
context: {}, | |
states: { | |
run : { | |
invoke : { | |
id : "id", | |
src : () => new Promise((resolve) => { | |
setTimeout(() => resolve({ | |
value : "VALUE", | |
}), 1000); | |
}), | |
onDone : [ | |
{ | |
target : "complete", | |
}, | |
{ | |
target : "complete", | |
actions : assign({ | |
value : (ctx, { data }) => data.value, | |
connection : (ctx, { data }) => { | |
data.field = data.value; | |
return data; | |
}, | |
}), | |
}, | |
], | |
onError : console.error, | |
}, | |
}, | |
complete : { | |
type : "final", | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment