# Included Middleware

Redux-bundler includes a few middlewares by default:

## Slightly modified `redux-thunk`

Works like `redux-thunk` except that everything is passed as a single argument and since all our selectors and action creators are attached to the store instance we also pass the store itself, plus anything bundles may have added by using `getExtraArgs`. So it ends up passing something like this as an argument `{dispatch, store, getState, ...extraArgs}` to your thunk function.

This lets you write action creators that don't care about argument position:

```javascript
export const doCoolStuff =
  () =>
  ({ dispatch, myApiWrapper }) => {
    dispatch({ type: 'USER_FETCH_STARTED' })
    return myApiWrapper('/some-resource')
      .then(payload => {
        dispatch({ type: 'USER_FETCH_FINISHED', payload })
      })
      .catch(() => {
        dispatch({ type: 'USER_FETCH_FAILED' })
      })
  }
```

## Debug Middleware

If you're using the `debugBundle` it will also add some logging middleware that logs actions and state with each action and shows you the next reactor that will be dispatched.

## Named Action Middleware

The bundle created by `createReactorBundle` will also inject middleware that allows you to dispatch an object that names the action creator to be used and optionally the arguments to pass to it.

For example dispatching `{actionCreator: 'doLogOut', args: [true]}` would be the same as calling `store.doLogOut(true)`.

This is most useful when writing reactor functions in a bundle where you may not have a direct reference to the action creator function you want to call.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://reduxbundler.com/api-reference/middlewares.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
