Skip to content

Instantly share code, notes, and snippets.

@franz101
Created March 2, 2020 12:47
Show Gist options
  • Save franz101/3b98f80b384d09f7c77ff393fe035de1 to your computer and use it in GitHub Desktop.
Save franz101/3b98f80b384d09f7c77ff393fe035de1 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: 'addresImport',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
UPLOAD: 'loading'
}
},
loading: {
on: {
RESOLVE: 'addressEditTable',
REJECT: 'failure'
}
},
addressEditTable: {
on: {
VALID: 'uploadAdress',
INVALID: 'uploadAdress',
RETRY: {
target: 'idle',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
},
uploadAdress: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target: 'idle',
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