Skip to content

Instantly share code, notes, and snippets.

@tmbtech
Created January 10, 2020 23:59
Show Gist options
  • Save tmbtech/742c9e87f08915ff1587b9ac35e6c9c4 to your computer and use it in GitHub Desktop.
Save tmbtech/742c9e87f08915ff1587b9ac35e6c9c4 to your computer and use it in GitHub Desktop.

Revisions

  1. tmbtech created this gist Jan 10, 2020.
    30 changes: 30 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    const Foobar = Machine({
    id: 'fetch',
    initial: 'loading',
    context: {
    patientID: null
    },
    states: {
    loading: {
    on: {
    "": [
    {
    target: "getPatientID",
    cond: "noPatientID"},
    {
    target: "getPatientProfilePromotionsAndBrands"}
    ]
    }
    },
    getPatientID: {
    onDone: "getPatientProfilePromotionsAndBrands"
    },
    getPatientProfilePromotionsAndBrands: {}
    }
    }, {
    guards: {
    "noPatientID": (context ) => {
    return context.patientID === null;
    }
    }
    });