# redux-promise-utils

> redux promise utils for you!

Latest version **1.0.4** (published 2019-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-promise-utils
pnpm add redux-promise-utils
yarn add redux-promise-utils
bun add redux-promise-utils
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-11-01 |
| First published | 2018-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YikaJ |
| Maintainers | jimklose |

## Links

- npm: https://www.npmjs.com/package/redux-promise-utils
- npm.io page: https://npm.io/package/redux-promise-utils

## Dependencies (1)

- [redux-actions](https://npm.io/package/redux-actions.md) ^2.6.1

## Recent versions

- 1.0.4 (latest) — 2019-11-01
- 1.0.3 — 2019-05-30
- 1.0.2 — 2019-05-21
- 1.0.1 — 2019-05-20
- 1.0.0 — 2018-10-24
- 0.2.4 — 2018-09-20
- 0.2.3 — 2018-09-20
- 0.2.1 — 2018-09-20
- 0.2.0 — 2018-09-20
- 0.1.0 — 2018-09-20
- 0.0.3 — 2018-09-20
- 0.0.2 — 2018-09-20
- 0.0.1 — 2018-09-20

## README

# redux-promise-utils

Based on [redux-thunk](https://github.com/reduxjs/redux-thunk) & [redux-actions](https://github.com/redux-utilities/redux-actions).

Easy utils to handle Promise in redux.

## Quick Start

### Install

use npm

```
npm i redux-promise-utils --save
```

use yarn

```
yarn add redux-promise-utils
```

## Usage

1. Ensure your reducer is handled by `redux-thunk`.
2. Ensure your api is a Promise.

```js
// data/action.js
import { createPromiseAction } from 'redux-promise-utils'
import * as api from './api'

export const fetchAction = createPromiseAction('fetchList', api.fetchList)

// data/reducer.js
import { createReducer } from 'redux-promise-utils'
import { fetchAction } from './action'

const initState = {}

const reducer = createReducer(initState)
    // catch sync action
    .which('SYNC_ACTION', (state, action) => {
        return state
    })
    // catch async action with three state
    .asyncWhich(fetchAction, {
        start(state, action) {
            return state
        },
        success(state, action) {
            return state
        },
        fail(state, action) {
            return state
        }
    })
    // build redux reducer handler
    .build()

export default reducer
```

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