src/index.js
/** Produces a set of actions that are bound to a specific store
 * The thunks object can contain action creators and/or thunks.
 * - Action creators: args => action
 *   are dispatched directly when called
 * - Thunks args => dispatch => dispatch(action)
 *   are called with dispatch as first argument.
 * The dispatch function will be patched to insert an action type if not given.
 * @param {Object} thunks
 * @param {Function} dispatch
 * @returns {object}
 */
Produces a set of actions that are bound to a specific store
The thunks object can contain action creators and/or thunks.
- Action creators: args => action
are dispatched directly when called
- Thunks args => dispatch => dispatch(action)
are called with dispatch as first argument.
The dispatch function will be patched to insert an action type if not given.
@param {Object} thunks
@param {Function} dispatch
@returns {object}
Produces a set of actions that are bound to a specific store The thunks object can contain action creators and / or thunks . - Action creators : args = > action are dispatched directly when called - Thunks args = > dispatch = > dispatch ( action ) are called with dispatch as first argument . The dispatch function will be patched to insert an action type if not given . @param { Object } thunks @param { Function } dispatch @returns { object }
function bindThunks(thunks, dispatch) {
  const boundThunks = {}
  for (let name of Object.keys(thunks)) {
    const defaultType = name
    const patchedDispatch = patchDispatch(dispatch, defaultType)
    boundThunks[name] = (...args) => {
      if (thunks[name] === null) thunks[name] = () => ({})
      const thunk = thunks[name](...args)
      if (typeof thunk === 'function') thunk(patchedDispatch)
      else patchedDispatch(thunk)
    }
  }
  return boundThunks
}
function bindThunks ( thunks , dispatch ) { const boundThunks = { } for ( let name of Object . keys ( thunks ) ) { const defaultType = name const patchedDispatch = patchDispatch ( dispatch , defaultType ) boundThunks [ name ] = ( ... args ) => { if ( thunks [ name ] === null ) thunks [ name ] = ( ) => ( { } ) const thunk = thunks [ name ] ( ... args ) if ( typeof thunk === 'function' ) thunk ( patchedDispatch ) else patchedDispatch ( thunk ) } } return boundThunks }
Produces a set of actions that are bound to a specific store
 The thunks object can contain action creators and/or thunks.
Produces a set of actions that are bound to a specific store The thunks object can contain action creators and / or thunks .