Skip to content

Instantly share code, notes, and snippets.

@dohoangdinhtien
Created September 18, 2020 12:26
Show Gist options
  • Save dohoangdinhtien/b2c540657de4e0b3333c1e819fa76fa3 to your computer and use it in GitHub Desktop.
Save dohoangdinhtien/b2c540657de4e0b3333c1e819fa76fa3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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