Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am parkerault on github.
  • I am parkerault (https://keybase.io/parkerault) on keybase.
  • I have a public key ASDgGe-7uPkk2rZFXFrlftfji08LADiThBae762fE6GUQgo

To claim this, I am signing this object:

@parkerault
parkerault / README.md
Last active March 14, 2018 20:37
Redux Modules w/ API Middleware

This is extracted from a project that's been in development for about two months; I tried to include just enough code to give you an idea how I restrict async operations to custom middleware and keep all actions synchronous and declarative. The original inspiration was the real-world example from redux. This isn't a terribly complicated example, but an action that kicks off a multi-step async function would have basically the same structure: the action provides whatever configuration is necessary to perform that task, and the middleware orchestrates the async control flow and dispatches intermediate actions as required. I know some people will say that moving async operations to a custom middleware instead of an action creator is just rearranging the deck chairs on the titanic, but in my experience it makes a huge difference as the project grows in complexity and prevents the action creators and reducers from devolving i

Component

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import JSONPointer from 'json-ptr';
import moment from 'moment';

import SVG from '../SVG';
import {
  deepCopyJSON,
# in a fresh repository
$ git --version
git version 2.17.1
$ mkdir foo && touch -- foo/bar
$ git stash push -u -m "test" foo
Saved working directory and index state On improvement/pam2-2779-add-types-to-entitiy-models: test
fatal: pathspec 'foo' did not match any files
error: unrecognized input
$ git stash show stash@{0}
# no output