title: Reducing redux-thunk boilerplate
body: <p>When writing <code>redux-thunk</code> functions, known as <em>thunks</em> there is allot of boilerplate that could be easily abstracted away. For example in most of our async API calls we are doing the following, without any side-effects:</p>
  
  <pre><code>export const LOGIN_REQUEST = 'my-app/auth/LOGIN_REQUEST';
  export const LOGIN_RECIEVE = 'my-app/auth/LOGIN_RECIEVE';
  export const LOGIN_FAILURE = 'my-app/auth/LOGIN_FAILURE';
  
  // ... reducer code here
  
  export function login(loginHandle, password) {
    return (dispatch, getState, api) =&gt; {
      dispatch({ type: LOGIN_REQUEST });
  
      api.post('/auth/login', { loginHandle, password }).then(
        response =&gt; dispatch({ type: LOGIN_RECIEVE, response }),
        error =&gt; dispatch({ type: LOGIN_FAILURE, error })
      );
    };
  }
  </code></pre>
  
  <p>Easy! Although as this covers at least 70% of our requests I'm sure there is an elegant way to abstract away allot of the above code to something like this (pseudo code):</p>
  
  <pre><code>export function login(loginHandle, password) {
    return (dispatch, getState, api) =&gt; api('POST', LOGIN_REQUEST, '/auth/login', { loginHandle, password });
  }
  </code></pre>
  
  <p>When we need to check the state and other side effects we can go back to a proper thunk. Although for most cases... we could cut this down?</p>
  
  <p><em>Any elegant ideas?</em></p>