Created
June 15, 2021 02:15
-
-
Save keithernet/a9e1b4a852b1de8c8eddc0895cb6435d 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 newMachine = { | |
id: 'newProduct', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
save: 'saving' | |
} | |
}, | |
saving: { | |
type: 'final' | |
} | |
} | |
}; | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'showingList', | |
context: { | |
products: [] | |
}, | |
states: { | |
showingList: { | |
on: { | |
newClicked: 'creatingNew' | |
} | |
}, | |
creatingNew: { | |
invoke: { | |
src: newMachine, | |
onDone: { | |
target: 'saved' | |
} | |
} | |
}, | |
saved: { | |
entry: 'addNewItem', | |
always: { | |
target: 'showingList' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment