# async-dispatch

> [![npm](https://img.shields.io/npm/v/async-dispatch.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/async-dispatch)

Latest version **1.0.10** (published 2020-08-03) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install async-dispatch
pnpm add async-dispatch
yarn add async-dispatch
bun add async-dispatch
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2020-08-03 |
| First published | 2020-06-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | ibrahim abushammah |
| Maintainers | ibrahimshamma99 |
| Keywords | redux, middleware |

## Links

- npm: https://www.npmjs.com/package/async-dispatch
- Repository: https://github.com/IbrahimShamma99/asynDispatch-middleware
- Homepage: https://github.com/IbrahimShamma99/asynDispatch-middleware#readme
- Issues: https://github.com/IbrahimShamma99/asynDispatch-middleware/issues
- npm.io page: https://npm.io/package/async-dispatch

## Dependencies (1)

- [rollup](https://npm.io/package/rollup.md) ^2.23.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.10 (latest) — 2020-08-03
- 1.0.9 — 2020-06-05
- 1.0.8 — 2020-06-05
- 1.0.7 — 2020-06-04
- 1.0.6 — 2020-06-04
- 1.0.5 — 2020-06-03
- 1.0.4 — 2020-06-03
- 1.0.3 — 2020-06-03
- 1.0.2 — 2020-06-03
- 1.0.1 — 2020-06-03
- 1.0.0 — 2020-06-03

## README

# async-dispatch middleware

[![npm](https://img.shields.io/npm/v/async-dispatch.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/async-dispatch)

> async-dispatch is a middleware can be added with no time to privilage the asynchronous server requests into your Redux store

For more informatiom about the future of redux-logger, check out the [discussion here](https://github.com/IbrahimShamma99/asynDispatch-middleware/issues).

## Table of contents

- [async-dispatch middleware](#async-dispatch-middleware)
  - [Table of contents](#table-of-contents)
  - [Install](#install)
  - [Usage](#usage)
  - [To Do](#to-do)
  - [License](#license)

## Install

`npm i --save async-dispatch`

## Usage

```javascript
import asyncDispatchMiddleware from "async-dispatch";
import { createStore } from "redux";
import { applyMiddleware } from "redux";

const store = createStore(
  rootReducer,
  applyMiddleware(asyncDispatchMiddleware)
);
// Note passing middleware as the third argument requires redux@>=3.1.0
```

Then applying this middleware is simple as

```js
const LoginReducer = (state = intialState, action) => {
    //actionTypes.LOGIN
      login(userData).then((data) => {
        if (data.error) {
          action.asyncDispatch({
            type: actionTypes.ERROR,
            message: data.error,
          });
        } else {
          action.asyncDispatch({
            type: actionTypes.SUCCESS,
            user: data,
            message: "Logged successfully",
          });
        }
      });
      return { ...state };
})

```
Meanwhile you are leveraging your store as usual as you used to do 
```js

  const mapDispatchToProps = (dispatch) => {
    return {
      submit: () => dispatch({ type: actionTypes.LOGIN })
      }
  }
  //Inside your component
  SubmitHandler = () => {
      return props.submit();
  }
```

## To Do

- [ ] Adding typeScript types

## License

MIT

---
_Source: https://npm.io/package/async-dispatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
