Skip to content

Instantly share code, notes, and snippets.

@chaance
Created October 9, 2020 21:16
Show Gist options
  • Save chaance/33e3e09b011020793ba3bbedc4406698 to your computer and use it in GitHub Desktop.
Save chaance/33e3e09b011020793ba3bbedc4406698 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 animationQueue = [];
class Queue {
enqueue(asyncTask) {
//
}
}
async function animate(direction) {
//
}
const queue = new Queue();
const fetchMachine = Machine({
id: 'scrollarea',
initial: 'IDLE',
context: {
retries: 0
},
states: {
IDLE: {
on: {
CLICK_TRACK: {
target: 'PAGING',
actions: []
},
}
},
PAGING: {
invoke: {
id: 'scrollByPage',
src: (_, event) => {
queue.enqueue(() => animate(event.direction))
},
onDone: {
target: 'IDLE',
},
onError: {
target: 'IDLE',
}
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment