Last active
April 1, 2020 08:05
-
-
Save traverse/ef1cad90f5b6ee531851362ad50f8026 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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