Skip to content

Instantly share code, notes, and snippets.

@easilyBaffled
Created December 18, 2019 17:03
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 easilyBaffled/1b6d6f94109e9263d7f60205521fbee6 to your computer and use it in GitHub Desktop.
Save easilyBaffled/1b6d6f94109e9263d7f60205521fbee6 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 IDLE = "idle",
PROCESSING = "processing",
PLAYING = "playing",
PAUSED = "paused";
const fetchMachine = Machine({
id: "fetch",
initial: IDLE,
context: {
retries: 0
},
states: {
[IDLE]: {
on: {
process: PROCESSING
}
},
[PROCESSING]: {
on: {
start: PLAYING,
end: IDLE,
pause: PAUSED
}
},
[PLAYING]: {
on: {
end: IDLE,
pause: PAUSED
}
},
[PAUSED]: {
on: {
end: IDLE,
resume: PLAYING
}
}
// 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