Skip to content

Instantly share code, notes, and snippets.

@jlengstorf
Created February 25, 2021 18:04
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 jlengstorf/dc3982465b7e148c9f5534d4f8459b58 to your computer and use it in GitHub Desktop.
Save jlengstorf/dc3982465b7e148c9f5534d4f8459b58 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: 'sub-queue',
initial: 'idle',
context: {},
states: {
idle: {
on: {
SUBSCRIPTION: 'starting'
}
},
starting: {
invoke: {
src: 'transition',
onDone: 'active'
}
},
active: {
invoke: {
src: 'display',
onDone: 'ending',
}
},
ending: {
invoke: {
src: 'transition',
onDone: 'idle'
}
},
}
}, {
services: {
transition() {
return new Promise((resolve) => {
setTimeout(resolve, 500);
});
},
display() {
return new Promise((resolve) => {
setTimeout(resolve, 5000);
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment