Skip to content

Instantly share code, notes, and snippets.

@horaciosystem
Last active March 30, 2021 18:33
Show Gist options
  • Save horaciosystem/ed0471b167c225140ae49604e035598d to your computer and use it in GitHub Desktop.
Save horaciosystem/ed0471b167c225140ae49604e035598d 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: 'editor',
initial: 'loading',
context: {
template: null
},
states: {
loading: {
on: {
RESOLVE: 'editting',
REJECT: 'failure'
}
},
editting: {
on: {
SAVE: 'loading'
}
},
failure: {
on: {
RETRY: {
target: 'loading',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment