Last active
June 20, 2020 11:38
-
-
Save pangratz/ff77b241ef8dc553b35978e024e3324e 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: 'pool', | |
type: "parallel", | |
context: { | |
past: [], | |
current: null, | |
queued: [1, 2, 3, 4] | |
}, | |
on: { | |
// remove an item | |
"REMOVE:ITEM": undefined, | |
// add an item | |
"ADD:ITEM": undefined, | |
// item has been removed from queue | |
"ITEM:REMOVED": undefined, | |
// new item added to queue | |
"ITEM:ADDED": undefined, | |
// item was active, but became inactive | |
// either because it finished by itself, | |
// or it has been finished from the outside | |
"ITEM:BECAME-INACTIVE": undefined, | |
// item became the current item | |
"ITEM:BECAME-CURRENT": undefined, | |
// send by the current item to indicate | |
// that it's state is finished | |
"CURRENT-ITEM:DID-FINISH": undefined, | |
// send when next item should become active | |
"USER:NEXT": undefined, | |
// send when the user wants to play/resume | |
// /pause playback | |
"USER:TOGGLE-PLAY-STATE": undefined, | |
// position of the item is updated | |
"USER:REORDER-ITEM": undefined, | |
// next item is selected randomly | |
"PLAYBACK:NEXT-SHUFFLE": undefined, | |
// next item is selcted in sequence | |
"PLAYBACK:NEXT-SEQUENCE": undefined, | |
// no next item after current finishes | |
"PLAYBACK:NEXT-OFF": undefined, | |
// repeat mode is toggled | |
"PLAYBACK:TOGGLE-REPEAT": undefined | |
}, | |
states: { | |
entries: { | |
type: "parallel", | |
states: { | |
past_items: { | |
initial : "empty", | |
states: { | |
empty: {}, | |
content: {} | |
} | |
}, | |
current_item: { | |
initial : "empty", | |
states: { | |
empty: {}, | |
content: {} | |
} | |
}, | |
next_item: { | |
initial : "empty", | |
states: { | |
empty: {}, | |
content: {} | |
} | |
}, | |
queued_items: { | |
initial : "empty", | |
states: { | |
empty: {}, | |
content: {} | |
} | |
} | |
} | |
}, | |
playback: { | |
type: "parallel", | |
states: { | |
state: { | |
initial: "stopped", | |
states: { | |
// current item is playing | |
started: {}, | |
// current item is paused | |
paused: {}, | |
// no current item | |
stopped: {} | |
} | |
}, | |
next_item: { | |
initial: "off", | |
states: { | |
// next item in queue | |
sequential: {}, | |
// next item is any from queue | |
shuffle: {}, | |
// no next item after current one | |
// finishes | |
off: {} | |
} | |
}, | |
// live/party OR normal/log | |
queue_mode: { | |
initial: "keep", | |
states: { | |
// finished item is added back to | |
// queue | |
keep: {}, | |
// finished item is removed | |
// from queue | |
remove: {} | |
} | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment