# redux-types

> Namespace type strings for redux dispatcher

Latest version **2.0.3** (published 2017-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-types
pnpm add redux-types
yarn add redux-types
bun add redux-types
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2017-09-13 |
| First published | 2016-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | jaketrent |
| Maintainers | jaketrent |
| Keywords | redux, react, flux, action, types, actions, types |

## Links

- npm: https://www.npmjs.com/package/redux-types
- Repository: https://github.com/jaketrent/redux-types
- Homepage: https://github.com/jaketrent/redux-types#readme
- Issues: https://github.com/jaketrent/redux-types/issues
- npm.io page: https://npm.io/package/redux-types

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2017-09-13
- 2.0.2 — 2017-09-12
- 2.0.1 — 2017-09-12
- 2.0.0 — 2017-09-12
- 1.0.0 — 2016-01-22

## README

# redux-types

Allows easy, consistent, and readable namespacing of redux actions.

## Why

Action types for the redux dispatcher must be unique.  An easy way to get uniqueness is with a namespace.  It is common, for instance, that you would `FETCH` things into many reducers.  But each `FETCH` must be distinguishable to the dispatcher.  To solve this problem, we might namespace the types to be `posts/FETCH` and `comments/FETCH`, mapping to names of some models or features in our app.

This library ensures that you follow this pattern, producing clean, readable action type namespacing.

The function will throw an error if one of the args are not a string, or if you pass the same string twice. 

## Install

```
npm install redux-types --save-dev
```
or
```
yarn add -D redux-types
```

## Usage

In your action `types.js` definition module, you might write:

```js
import types from 'redux-types'

const typesArray = ['CREATE', 'EDIT', 'DELETE'];

export default types('posts', typesArray)
```

You can also compose arrays for a better DRY styled code :

```js
import types from 'redux-types'

const CRUDTypes = ['CREATE', 'EDIT', 'DELETE']; // both arrays could be 
const fetchTypes = ['FETCH_SUCCESS', 'FETCH_PENDING', 'FETCH_ERROR']; // imported from a constants file
const someSpeficicAction = 'SPECIFIC';

export const PostTypes = [...CRUDTypes, ...fetchTypes, someSpeficicAction]; // exported for tests purposes

export default types('posts', PostTypes)
```

And then be able to use these in your `actions.js` creators:

```js
import TYPES from './types'

export function createPost(post) {
  return {
    type: TYPES.CREATE,
    post
  }
}
```

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