Created
October 9, 2020 21:16
-
-
Save chaance/33e3e09b011020793ba3bbedc4406698 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 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