Skip to content

Instantly share code, notes, and snippets.

@tmikeschu
Last active May 3, 2021 20:06

Revisions

  1. tmikeschu revised this gist May 3, 2021. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -26,12 +26,6 @@
    freeContactAdmin: {
    type: "final"
    },
    fullContactAdmin: {
    type: "final"
    },
    adminPaywall: {
    type: "final",
    },
    proOrEnterprise: {
    on: {
    YES: "continue",
    @@ -71,7 +65,13 @@
    YES: "fullContactAdmin",
    NO: "adminPaywall"
    }
    }
    },
    fullContactAdmin: {
    type: "final"
    },
    adminPaywall: {
    type: "final",
    },
    }
    });

  2. tmikeschu created this gist May 3, 2021.
    77 changes: 77 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,77 @@

    // Available variables:
    // - Machine
    // - interpret
    // - assign
    // - send
    // - sendParent
    // - spawn
    // - raise
    // - actions
    // - XState (all XState exports)

    const fetchMachine = Machine({
    id: 'workflow-limits',
    initial: 'userIsFree',
    context: {
    retries: 0
    },
    states: {
    userIsFree: {
    on: {
    YES: "freeContactAdmin",
    NO: "proOrEnterprise"
    }
    },
    freeContactAdmin: {
    type: "final"
    },
    fullContactAdmin: {
    type: "final"
    },
    adminPaywall: {
    type: "final",
    },
    proOrEnterprise: {
    on: {
    YES: "continue",
    NO: "isFreeTrial"
    }
    },
    continue: {
    type: "final"
    },
    isFreeTrial: {
    on: {
    YES: "continue",
    NO: "atWorkflowLimit"
    }
    },
    atWorkflowLimit: {
    on: {
    YES: "modify",
    NO: "continue"
    }
    },
    modify: {
    on: {
    EDIT: "workflowIsFirst5",
    CREATE: "isFullMember",
    UNARCHIVE: "isFullMember",
    }
    },
    workflowIsFirst5: {
    on: {
    YES: "continue",
    NO: "isFullMember",
    }
    },
    isFullMember: {
    on: {
    YES: "fullContactAdmin",
    NO: "adminPaywall"
    }
    }
    }
    });