Skip to content

Instantly share code, notes, and snippets.

@traverse
Last active April 1, 2020 08:05
Show Gist options
  • Save traverse/ef1cad90f5b6ee531851362ad50f8026 to your computer and use it in GitHub Desktop.
Save traverse/ef1cad90f5b6ee531851362ad50f8026 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: 'status',
initial: 'indeterminate',
context: {
color: 'orange',
icon: 'halt'
},
states: {
indeterminate: {
on: {
CLICK: {
target: 'awaitingApproval',
actions: assign({
color: 'blue',
icon: 'letter'
})
}
}
},
awaitingApproval: {
on: {
CLICK: {
target: 'approved',
actions: assign({
color: 'green',
icon: 'thumbsup'
})
}
}
},
approved: {
on: {
CLICK: {
target: 'declined',
actions: assign({
color: 'red',
icon: 'thumbsdown'
})
}
}
},
declined: {
on: {
CLICK: {
target: 'indeterminate',
actions: assign({
color: 'orange',
icon: 'halt'
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment