Skip to content

Instantly share code, notes, and snippets.

@gltovar
Created September 23, 2019 04:50
Show Gist options
  • Save gltovar/26d27d9fe2416bf2e043bdae49e3263f to your computer and use it in GitHub Desktop.
Save gltovar/26d27d9fe2416bf2e043bdae49e3263f 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: 'infoChunk',
initial: 'loading',
states: {
loading: {
on: {
MARKED_FOR_DELETION: 'pendingDeletion',
MARKED_FOR_EDIT: 'pendingEdit',
RECEIVE_DATA: 'idle'
}
},
pendingDeletion: {
on: {
SELECT: 'reviewDeletion'
}
},
reviewDeletion: {
on: {
DELETE: 'complete',
KEEP: 'complete',
CANCEL: 'pendingDeletion'
}
},
pendingEdit: {
on: {
SELECT: 'reviewEdit'
}
},
reviewEdit: {
on: {
ACCEPT: 'complete',
REJECT: 'complete',
CANCEL: 'pendingEdit'
}
},
idle: {
on: {
SELECT: 'edit'
}
},
edit: {
on: {
UPDATE: 'complete',
DELETE: 'confirmDeletion',
CANCEL: 'idle'
}
},
confirmDeletion: {
on: {
DELETE: 'complete',
CANCEL: 'edit'
}
},
complete: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment