Skip to content

Instantly share code, notes, and snippets.

@She-Codes
Created March 23, 2020 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save She-Codes/339389c9c061d75d904a948803a22e10 to your computer and use it in GitHub Desktop.
Save She-Codes/339389c9c061d75d904a948803a22e10 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const commentModalMachine = Machine({
id: 'commentModal',
initial: 'closed',
context: {
comment: 'This is a comment'
},
states: {
closed: {
on: {
OPEN: {
target: 'open'
}
}
},
open: {
initial: 'notEditing',
states: {
notEditing: {
on: {
EDIT: {
target: 'editing'
}
}
},
editing: {
on: {
CANCEL: {
target: 'notEditing'
},
SAVE: 'updating'
}
},
updating: {
on: {
SUCCESS: 'notEditing',
ERROR: 'notEditing',
CLOSE: undefined // closing modal while updating not allowed
}
}
}
}
},
on: {
CLOSE: 'closed'
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment