Skip to content

Instantly share code, notes, and snippets.

@charlie632
Last active June 9, 2021 14:22
Show Gist options
  • Select an option

  • Save charlie632/027a8c6e650793aa347830c498a43908 to your computer and use it in GitHub Desktop.

Select an option

Save charlie632/027a8c6e650793aa347830c498a43908 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: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
PERMISSION_PENDING: 'membership',
PEMISSION_ACTIVE: 'success'
}
},
membership: {
on: {
MISSING_PROXY: 'connect_proxy',
PENDING_INVITE: 'pending_invite',
INSIDE_BUSINESS: 'success',
USER_ASSOCIATION: 'notify_user',
ERROR: 'error'
}
},
notify_user: {
on: {
CONFIRM: 'success'
}
},
connect_proxy: {
on: {
CONNECT: 'membership'
}
},
pending_invite: {
on: {
RETRY: 'membership'
}
},
error: {
type: 'final'
},
success: {
type: 'final'
},/*
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