Skip to content

Instantly share code, notes, and snippets.

@joshpitzalis
Last active February 20, 2020 04:09
Show Gist options
  • Save joshpitzalis/e51de4a18bd4d19a84ecb3f15bba5ef2 to your computer and use it in GitHub Desktop.
Save joshpitzalis/e51de4a18bd4d19a84ecb3f15bba5ef2 to your computer and use it in GitHub Desktop.

Revisions

  1. joshpitzalis revised this gist Feb 20, 2020. No changes.
  2. joshpitzalis created this gist Feb 20, 2020.
    45 changes: 45 additions & 0 deletions machine.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@

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

    const fetchMachine = Machine({
    id: 'contactChunks',
    initial: 'idle',
    states: {
    idle: {
    on: {
    FETCHED: 'loading',
    ALREADY_FETCHED:'selector',
    }
    },
    loading: {
    on: {
    RESOLVED: 'selector',
    REJECTED: 'error'
    }
    },
    selector: {
    onEntry: ['deduplicate', 'preSelect'],
    on: {
    SELECTED: 'selector',
    CANCELLED: 'idle',
    REVEALED_MORE:'selector',
    }
    },
    error: {
    on: {
    RETRIED: 'loading'
    }
    }
    }

    });