Skip to content

Instantly share code, notes, and snippets.

@the-main-thing
Created February 3, 2020 13:02
Show Gist options
  • Save the-main-thing/9240b33809198b2526ecc5733b596807 to your computer and use it in GitHub Desktop.
Save the-main-thing/9240b33809198b2526ecc5733b596807 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 fetchMachine = Machine({
id: 'dataBoard',
initial: 'idle',
context: {
currentId: null
},
states: {
idle: {
on: {
ADD: 'add',
EDIT: 'edit',
DELETE: 'confirm_delete'
}
},
confirm_delete: {
on: {
DELETE: 'delete',
CANCEL: 'idle'
}
},
'delete': {
on: {
COMPLETE: 'idle',
ERROR: 'error'
}
},
add: {
on: {
SAVE: 'saving_new',
CANCEL: 'idle'
}
},
saving_new: {
on: {
COMPLETE: 'idle',
ERROR: 'error'
}
},
error: {
on: {
RESET: 'idle'
}
},
edit: {
on: {
SAVE: 'saving_change',
}
},
saving_change: {
on: {
COMPLETE: 'idle',
ERROR: 'error'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment