Skip to content

Instantly share code, notes, and snippets.

@NikolaRusakov
Last active November 29, 2019 22:52
Show Gist options
  • Select an option

  • Save NikolaRusakov/fb93859e580fef97869bb43e281e60d2 to your computer and use it in GitHub Desktop.

Select an option

Save NikolaRusakov/fb93859e580fef97869bb43e281e60d2 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: 'fetch',
initial: 'overview',
context: {
retries: 0
},
states: {
overview: {
on: {
TO_TECH_DETAIL: 'techDetail',
TO_DETAIL: 'detail',
}
},
detail: {
on: {
TO_TECH_DETAIL: 'techDetail',
CLOSE: 'leave',
}
},
techDetail: {
on: {
TO_DETAIL: 'detail',
CLOSE: 'leave',
}
},
leave: {
type: 'final',
on: {
ON_PROGRESS_CLOSE: 'overview',
ON_CLOSE: 'overview',
}
},
failure: {
on: {
TO_TECH_DETAIL: {
target: 'detail',
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