Skip to content

Instantly share code, notes, and snippets.

@rads
Created November 27, 2019 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rads/736b70e57a01a41371e74d7b1f135b7d to your computer and use it in GitHub Desktop.
Save rads/736b70e57a01a41371e74d7b1f135b7d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
// Initial state
initial: 'idle',
// States
states: {
idle: {
on: {
FETCH: 'pending'
}
},
pending: {
on: {
FULFILL: 'success',
REJECT: 'failure'
}
},
success: {
// Initial child state
initial: 'items',
// Child states
states: {
items: {
on: {
'ITEM.CLICK': 'item'
}
},
item: {
on: {
BACK: 'items'
}
}
}
},
failure: {
on: {
RETRY: 'pending'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment