Skip to content

Instantly share code, notes, and snippets.

@saadshahd
Last active November 4, 2020 12:10
Show Gist options
  • Save saadshahd/30e6c3d66ea00c23ffdeead749a8dafe to your computer and use it in GitHub Desktop.
Save saadshahd/30e6c3d66ea00c23ffdeead749a8dafe 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 stateMachine = Machine({
id: "status",
type: "parallel",
states: {
info: {
initial: "Created",
on: {
FORFEITED: '.Forfeited',
CANCELLED: '.Cancelled',
},
states: {
Created: {
on: {
INFO_OFFICIALLY_SCHEDULED: {
target: "OfficiallyScheduled",
actions: ["scheduleVideo"]
},
INFO_READY_FOR_COLLECTION: "ReadyForCollection"
}
},
OfficiallyScheduled: {
on: {
INFO_READY_FOR_COLLECTION: "ReadyForCollection"
}
},
ReadyForCollection: {},
Forfeited: {},
Cancelled: {}
}
},
collection: {
initial: "NotStarted",
on: {
FORFEITED: '.NotStarted',
CANCELLED: '.NotStarted',
},
states: {
NotStarted: {
on: {
COLLECTION_START: "InProgress",
COLLECTION_COMPLETE: "Complete"
}
},
InProgress: {
on: {
COLLECTION_COMPLETE: "Complete"
}
},
Complete: {
on: {
COLLECTION_INCOMPLETE: "InProgress"
}
}
}
},
ops: {
initial: "Unassigned",
on: {
FORFEITED: '.Unassigned',
CANCELLED: '.Unassigned',
},
states: {
Unassigned: {
on: {
OPS_ASSIGN: "Assigned"
}
},
Assigned: {
on: {
OPS_UNASSIGN: "Unassigned"
}
}
}
},
video: {
initial: "Untracked",
on: {
FORFEITED: '.Untracked',
CANCELLED: '.Untracked',
},
states: {
Untracked: {
initial: "idle",
on: {
VIDEO_SCHEDULED: "Scheduled",
VIDEO_FOUND: "Found",
VIDEO_NOT_FOUND: "NotFound"
},
states: {
idle: {
on: {
VIDEO_SCHEDULE: "scheduling"
}
},
scheduling: {
invoke: {
id: "scheduleVideo",
src: "scheduleVideo",
onDone: {
target: "#VideoScheduled"
}
}
}
}
},
Scheduled: {
id: "VideoScheduled",
on: {
VIDEO_FOUND: "Found",
VIDEO_NOT_FOUND: "NotFound"
}
},
NotFound: {
on: {
VIDEO_FOUND: "Found"
}
},
Found: {}
}
},
sbd: {
initial: 'NotImported',
on: {
FORFEITED: '.NotImported',
CANCELLED: '.NotImported',
},
states: {
NotImported: {
on: {
SBD_IMPORT_START: 'Processing',
SBD_IMPORT_SUCCESS: 'Available',
SBD_IMPORT_FAILED: 'Failed',
},
},
Processing: {
on: {
SBD_IMPORT_SUCCESS: 'Available',
SBD_IMPORT_FAILED: 'Failed',
},
},
Failed: {
on: {
SBD_IMPORT_START: 'Processing',
},
},
Available: {
on: {
SBD_IMPORT_START: 'Updating',
SBD_IMPORT_FAILED: 'Failed',
},
},
Updating: {
on: {
SBD_IMPORT_SUCCESS: 'Updated',
SBD_IMPORT_FAILED: 'FailedUpdate',
},
},
Updated: {
on: {
SBD_IMPORT_START: 'Updating',
SBD_IMPORT_FAILED: 'FailedUpdate',
},
},
FailedUpdate: {
on: {
SBD_IMPORT_START: 'Updating',
},
},
},
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment