Skip to content

Instantly share code, notes, and snippets.

@saadshahd
Last active September 7, 2020 14:07
Show Gist options
  • Save saadshahd/b7566849d96676ac76bca2bd758e8f51 to your computer and use it in GitHub Desktop.
Save saadshahd/b7566849d96676ac76bca2bd758e8f51 to your computer and use it in GitHub Desktop.

Revisions

  1. saadshahd revised this gist Sep 7, 2020. 1 changed file with 89 additions and 11 deletions.
    100 changes: 89 additions & 11 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -103,40 +103,115 @@ const statusMachine = Machine({
    },
    qa: {
    // type: 'parallel',
    initial: 'Unreviewed',
    initial: "Unreviewed",
    states: {
    Unreviewed: {
    on: {
    FACTS_REVIEW: 'FactsReviewed'
    FACTS_REVIEW: "FactsReviewed"
    }
    },
    FactsReviewed: {
    on: {
    PASSIVE_REVIEW: 'Passive'
    PASSIVE_REVIEW: "Passive",
    ACTIVE_REVIEW: "Active"
    }
    },
    Passive: {
    type: 'parallel',
    type: "parallel",
    states: {
    RawData: {
    initial: 'NotStarted',
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    PASSIVE_REVIEW_RAWDATA: 'Started'
    PASSIVE_REVIEW_RAWDATA_START: "Started"
    }
    },
    Started: {
    on: {
    CHANGE: 'Changed',
    COMPLETE: 'Completed'
    PASSIVE_REVIEW_RAWDATA_CHANGE: "Changed",
    PASSIVE_REVIEW_RAWDATA_COMPLETE: "Completed"
    }
    },
    Changed: {
    type: 'final'
    type: "final"
    },
    Completed: {
    type: 'final'
    type: "final"
    }
    }
    },
    Location: {
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    PASSIVE_REVIEW_LOCATION_START: "Started"
    }
    },
    Started: {
    on: {
    PASSIVE_REVIEW_LOCATION_CHANGE: "Changed",
    PASSIVE_REVIEW_LOCATION_COMPLETE: "Completed"
    }
    },
    Changed: {
    type: "final"
    },
    Completed: {
    type: "final"
    }
    }
    },
    FreezeFrame: {
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    PASSIVE_REVIEW_FREEZEFRAME_START: "Started"
    }
    },
    Started: {
    on: {
    PASSIVE_REVIEW_FREEZEFRAME_CHANGE: "Changed",
    PASSIVE_REVIEW_FREEZEFRAME_COMPLETE: "Completed"
    }
    },
    Changed: {
    type: "final"
    },
    Completed: {
    type: "final"
    }
    }
    }
    },
    on: {
    ACTIVE_REVIEW: "Active"
    }
    },
    Active: {
    type: "parallel",
    states: {
    RawData: {
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    ACTIVE_REVIEW_RAWDATA_START: "Started"
    }
    },
    Started: {
    on: {
    ACTIVE_REVIEW_RAWDATA_CHANGE: "Changed",
    ACTIVE_REVIEW_RAWDATA_COMPLETE: "Completed"
    }
    },
    Changed: {
    type: "final"
    },
    Completed: {
    type: "final"
    }
    }
    }
    @@ -159,7 +234,10 @@ const statusMachine = Machine({
    }
    },
    Complete: {
    type: "final"
    type: "final",
    on: {
    UPDATE: "InProgress"
    }
    },
    Failed: {
    on: {
  2. saadshahd created this gist Sep 7, 2020.
    172 changes: 172 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,172 @@
    const statusMachine = Machine({
    id: "status",
    type: "parallel",
    states: {
    info: {
    initial: "Created",
    states: {
    Created: {
    on: {
    OFFICIALLY_SCHEDULED: "OfficiallyScheduled"
    }
    },
    OfficiallyScheduled: {
    entry: ["scheduleVideo", "scheduleLineups"],
    on: {
    READY_FOR_COLLECTION: "ReadyForCollection"
    }
    },
    ReadyForCollection: {
    on: {
    READY_FOR_IQ: "ReadyForIQ"
    }
    },
    ReadyForIQ: {
    type: "final"
    }
    }
    },
    ops: {
    initial: "Unassigned",
    states: {
    Unassigned: {
    on: {
    ASSIGN: "Assigned"
    }
    },
    Assigned: {
    on: {
    UNASSIGN: "Unassigned"
    }
    }
    }
    },
    video: {
    initial: "Unavailable",
    states: {
    Unavailable: {
    on: {
    FOUND: "Available"
    }
    },
    Available: {
    type: "final"
    }
    }
    },
    collection: {
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    START: "Started"
    }
    },
    Started: {
    on: {
    COMPLETE_TAG: "PendingValidation"
    }
    },
    PendingValidation: {
    on: {
    VALIDATE: "Complete",
    INVALIDATE: "Invalid",
    NO_FF: "WithoutFF",
    NO_LOCATION: "WithoutLocation",
    NO_DIRECTION: "WithoutDirection"
    }
    },
    WithoutLocation: {
    on: {
    LOCATION_ADDED: "PendingValidation"
    }
    },
    WithoutFF: {
    on: {
    FF_ADDED: "PendingValidation"
    }
    },
    WithoutDirection: {
    on: {
    DIRECTION_ADDED: "PendingValidation"
    }
    },
    Invalid: {
    on: {
    VALIDATE: "PendingValidation"
    }
    },
    Complete: {
    type: "final"
    }
    }
    },
    qa: {
    // type: 'parallel',
    initial: 'Unreviewed',
    states: {
    Unreviewed: {
    on: {
    FACTS_REVIEW: 'FactsReviewed'
    }
    },
    FactsReviewed: {
    on: {
    PASSIVE_REVIEW: 'Passive'
    }
    },
    Passive: {
    type: 'parallel',
    states: {
    RawData: {
    initial: 'NotStarted',
    states: {
    NotStarted: {
    on: {
    PASSIVE_REVIEW_RAWDATA: 'Started'
    }
    },
    Started: {
    on: {
    CHANGE: 'Changed',
    COMPLETE: 'Completed'
    }
    },
    Changed: {
    type: 'final'
    },
    Completed: {
    type: 'final'
    }
    }
    }
    }
    }
    }
    },
    importer: {
    initial: "NotStarted",
    states: {
    NotStarted: {
    on: {
    START: "InProgress"
    }
    },
    InProgress: {
    on: {
    SUCCESS: "Complete",
    FAIL: "Failed"
    }
    },
    Complete: {
    type: "final"
    },
    Failed: {
    on: {
    RETRY: "InProgress"
    }
    }
    }
    }
    }
    });