Last active
January 27, 2021 03:50
-
-
Save fiddlerwoaroof/6f4d41e8ebe81cffa3c77fd02b51084b 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const machineDefinition = { | |
id: "address-book", | |
initial: "start", | |
context: { contacts: [] }, | |
states: { | |
start: { | |
on: { | |
select_contact: "showing_contact", | |
new_contact: "adding_contact", | |
}, | |
}, | |
showing_contact: {type:'parallel', states:{a:{ | |
initial: "viewing", | |
context: { | |
contact: { | |
name: "", | |
address: "", | |
phone_number: "", | |
}, | |
}, | |
states: { | |
viewing: { | |
on: { | |
edit_name: "editing_name", | |
edit_address: "editing_address", | |
edit_phone_number: "editing_phone_number", | |
}, | |
}, | |
editing_name: { | |
on: { save: "viewing" }, | |
}, | |
editing_address: { | |
on: { save: "viewing" }, | |
}, | |
editing_phone_number: { | |
on: { save: "viewing" }, | |
}, | |
}, | |
on: { | |
deselect: "", | |
}, | |
},b:{ | |
initial: "viewing", | |
context: { | |
contact: { | |
name: "", | |
address: "", | |
phone_number: "", | |
}, | |
}, | |
states: { | |
viewing: { | |
on: { | |
edit_name: "editing_name", | |
edit_address: "editing_address", | |
edit_phone_number: "editing_phone_number", | |
}, | |
}, | |
editing_name: { | |
on: { save: "viewing" }, | |
}, | |
editing_address: { | |
on: { save: "viewing" }, | |
}, | |
editing_phone_number: { | |
on: { save: "viewing" }, | |
}, | |
}, | |
on: { | |
deselect: "", | |
}, | |
}}}, | |
adding_contact: { | |
on: { | |
save: "showing_contact", | |
}, | |
}, | |
}, | |
}; | |
const fetchMachine = Machine(machineDefinition); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment