Skip to content

Instantly share code, notes, and snippets.

@matthewlehner
Last active March 2, 2020 21:14
Show Gist options
  • Select an option

  • Save matthewlehner/49b0c5d3e3358f6dc03741f546cdc41a to your computer and use it in GitHub Desktop.

Select an option

Save matthewlehner/49b0c5d3e3358f6dc03741f546cdc41a to your computer and use it in GitHub Desktop.

Revisions

  1. matthewlehner revised this gist Mar 2, 2020. 1 changed file with 18 additions and 3 deletions.
    21 changes: 18 additions & 3 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -10,17 +10,32 @@ const voteMachine = Machine({
    },
    greetingMsg: {
    on: {
    GREETING_FINISHED: "pinPrompt"
    GREETING_FINISHED: "pinPromptMsg"
    }
    },
    pinPromptMsg: {
    on: {
    PIN_PROMPT_MSG_FINISHED: "pinPrompt"
    }
    },
    pinPrompt: {
    on: {
    PIN_SUCCESS: "registrationNumberPrompt"
    PIN_SUCCESS: "registrationNumberPromptMsg"
    }
    },
    registrationNumberPromptMsg: {
    on: {
    REGISTRATION_PROMPT_MSG_FINISHED: "registrationNumberPrompt"
    }
    },
    registrationNumberPrompt: {
    on: {
    REGISTRATION_NO_SUCCESS: "dobPrompt"
    REGISTRATION_NO_SUCCESS: "dobPromptMsg"
    }
    },
    dobPromptMsg: {
    on: {
    DOB_PROMPT_MSG_FINISHED: "dobPrompt"
    }
    },
    dobPrompt: {
  2. matthewlehner created this gist Mar 2, 2020.
    48 changes: 48 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    const voteMachine = Machine({
    id: "Phone Voting",
    initial: "idle",
    context: {},
    states: {
    idle: {
    on: {
    CALL_ANSWERED: "greetingMsg"
    }
    },
    greetingMsg: {
    on: {
    GREETING_FINISHED: "pinPrompt"
    }
    },
    pinPrompt: {
    on: {
    PIN_SUCCESS: "registrationNumberPrompt"
    }
    },
    registrationNumberPrompt: {
    on: {
    REGISTRATION_NO_SUCCESS: "dobPrompt"
    }
    },
    dobPrompt: {
    on: {
    DOB_SUCCESS: "voteDisclaimerMessage"
    }
    },
    voteDisclaimerMessage: {
    on: {
    VOTE_DISCLAIMER_MESSAGE_COMPLETE: "ballotFlow"
    }
    },
    ballotFlow: {
    on: {
    CAPTURE_ALL_BALLOT_OPTIONS: "recordBallot"
    }
    },
    recordBallot: {
    on: {
    SERVER_RECORDED_BALLOT: "success"
    }
    },
    success: {}
    }
    });