Skip to content

Instantly share code, notes, and snippets.

@korshunad
Created June 30, 2021 22:02
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 korshunad/d8afb85180aca74314ac18c4628fec84 to your computer and use it in GitHub Desktop.
Save korshunad/d8afb85180aca74314ac18c4628fec84 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 joinDropMachine = Machine(
{
id: 'joinDrop',
initial: 'unknown',
context: {},
states: {
unknown: {
always: [
{
target: '#countdown',
cond: 'isCountingDown',
},
{
target: '#waitingRoomOpen',
cond: 'isWaitingRoomOpen',
},
{
target: '#queueOpen',
cond: 'isQueueOpen',
},
{
target: '#queueClosed',
cond: 'isQueueClosed',
},
{
target: '#unavailable',
},
],
},
unavailable: {
id: 'unavailable',
on: {
COUNTDOWN_OPEN: {
target: '#countdown',
},
},
},
countdown: {
id: 'countdown',
initial: 'unknown',
on: {
WAITING_ROOM_OPEN: {
target: '#waitingRoomOpen',
},
},
states: {
unknown: {
always: [
{
target: '#countdown.eligible',
cond: 'isEligible',
},
{
target: '#countdown.ineligible',
},
],
},
eligible: {
},
ineligible: {
},
},
},
waitingRoomOpen: {
id: 'waitingRoomOpen',
initial: 'unknown',
on: {
QUEUE_OPEN: {
target: '#queueOpen',
},
},
states: {
unknown: {
always: [
{
target: '#waitingRoomOpen.eligible',
cond: 'isEligible',
},
{
target: '#waitingRoomOpen.ineligible',
},
],
},
eligible: {
},
ineligible: {
},
},
},
queueOpen: {
id: 'queueOpen',
initial: 'unknown',
states: {
unknown: {
always: [
{
target: '#queueOpen.eligible',
cond: 'isEligible',
},
{
target: '#queueOpen.ineligible',
},
],
},
eligible: {
states: {
enqueuing: {},
enqueueFailed: {},
enqueueSuccess: {},
},
on: {
GO_TO_QUEUE: {
target: '#queueOpen.eligible.enqueuing',
},
},
},
ineligible: {},
},
},
queueClosed: {
id: 'queueClosed',
type: 'final',
},
},
},
{
guards: {
isCountingDown: () => {},
isWaitingRoomOpen: () => true,
isQueueOpen: () => {},
isQueueClosed: () => {},
isEligible: () => {},
isIneligible: () => {},
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment