Skip to content

Instantly share code, notes, and snippets.

@zettadam
Last active February 25, 2020 06:40
Show Gist options
  • Select an option

  • Save zettadam/2ec7ad6acf0f5ae658f03c4eef4a86a2 to your computer and use it in GitHub Desktop.

Select an option

Save zettadam/2ec7ad6acf0f5ae658f03c4eef4a86a2 to your computer and use it in GitHub Desktop.

Revisions

  1. zettadam revised this gist Feb 25, 2020. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -26,15 +26,20 @@
    },
    submitted: {
    on: {
    RESOLVE: 'processed',
    RESOLVE: 'pending',
    REJECT: 'rejected',
    CANCEL: 'withdrawn'
    }
    },
    pending: {
    on: {
    RESOLVE: 'processed'
    }
    },
    processed: {
    on: {
    PUBLISH: 'published',
    SUBMIT: 'submitted',
    RESUBMIT: 'submitted',
    WITHDRAW: 'withdrawn'
    }
    },
    @@ -45,7 +50,7 @@
    },
    withdrawn: {
    on: {
    SUBMIT: 'submitted',
    RESUBMIT: 'submitted',
    DELETE: 'deleted'
    }
    },
  2. zettadam revised this gist Feb 25, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    // - XState (all XState exports)

    const fetchMachine = Machine({
    id: 'schedule-status',
    id: 'flight-assignment-status',
    initial: 'idle',
    states: {
    idle: {
  3. zettadam revised this gist Feb 25, 2020. No changes.
  4. zettadam revised this gist Feb 25, 2020. No changes.
  5. zettadam revised this gist Feb 25, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@
    on: {
    RESOLVE: 'processed',
    REJECT: 'rejected',
    WITHDRAW: 'withdrawn'
    CANCEL: 'withdrawn'
    }
    },
    processed: {
    @@ -45,7 +45,7 @@
    },
    withdrawn: {
    on: {
    CREATE: 'created',
    SUBMIT: 'submitted',
    DELETE: 'deleted'
    }
    },
  6. zettadam created this gist Feb 25, 2020.
    60 changes: 60 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@

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

    const fetchMachine = Machine({
    id: 'schedule-status',
    initial: 'idle',
    states: {
    idle: {
    on: {
    CREATE: 'created'
    }
    },
    created: {
    on: {
    SUBMIT: 'submitted'
    }
    },
    submitted: {
    on: {
    RESOLVE: 'processed',
    REJECT: 'rejected',
    WITHDRAW: 'withdrawn'
    }
    },
    processed: {
    on: {
    PUBLISH: 'published',
    SUBMIT: 'submitted',
    WITHDRAW: 'withdrawn'
    }
    },
    rejected: {
    on: {
    SUBMIT: 'submitted'
    }
    },
    withdrawn: {
    on: {
    CREATE: 'created',
    DELETE: 'deleted'
    }
    },
    deleted: {
    type: 'final'
    },
    published: {
    type: 'final'
    }
    }
    });