Skip to content

Instantly share code, notes, and snippets.

@wlepinski
Created February 22, 2023 19:41
Show Gist options
  • Save wlepinski/27c4829187084fac0442cc3025d86c8a to your computer and use it in GitHub Desktop.
Save wlepinski/27c4829187084fac0442cc3025d86c8a to your computer and use it in GitHub Desktop.

Revisions

  1. wlepinski revised this gist Feb 22, 2023. No changes.
  2. wlepinski revised this gist Feb 22, 2023. No changes.
  3. wlepinski created this gist Feb 22, 2023.
    51 changes: 51 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@

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

    const fetchMachine = Machine({
    id: 'workflow',
    initial: 'draft',
    context: {
    retries: 0
    },
    states: {
    draft: {
    on: {
    IMPLEMENT: 'implement'
    }
    },
    implement: {
    on: {
    RUN: 'running'
    }
    },
    running: {
    on: {
    PAUSE: 'paused',
    STOP: 'analysis'
    }
    },
    paused: {
    on: {
    RESUME: 'running'
    }
    },
    analysis: {
    on: {
    COMPLETE: 'completed'
    }
    },
    completed: {
    final: true
    }
    }
    });