Created
September 18, 2020 12:26
-
-
Save dohoangdinhtien/b2c540657de4e0b3333c1e819fa76fa3 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 makes = [ | |
{ id: 1, name: "Toyota" }, | |
{ id: 2, name: "Honda" }, | |
{ id: 3, name: "ISUZU" }, | |
]; | |
const mmyMachine = Machine({ | |
id: 'mmy', | |
initial: 'idle', | |
context: { | |
/* some data */ | |
makeList: [], | |
}, | |
states: { | |
idle: { | |
on: { | |
FETCH: 'loading' | |
} | |
}, | |
loading: { | |
invoke: { | |
id: 'getMake', | |
src: (context, event) => makes, | |
onDone: { | |
target: 'success', | |
actions: [ | |
assign({ makeList: (context, event) => context.makeList = makes }), | |
context => console.log(context.makeList) | |
] | |
} | |
} | |
}, | |
success: {}, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment