# redux-action-type

Latest version **1.0.5** (published 2018-12-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install redux-action-type
pnpm add redux-action-type
yarn add redux-action-type
bun add redux-action-type
```

## 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 | 1.0.5 |
| Published | 2018-12-05 |
| First published | 2018-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | starvinmelon |

## Links

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

## Dependencies (3)

- [redux](https://npm.io/package/redux.md) ^4.0.1
- [ts-node](https://npm.io/package/ts-node.md) ^7.0.1
- [typescript](https://npm.io/package/typescript.md) ^3.2.1

## Recent versions

- 1.0.5 (latest) — 2018-12-05
- 1.0.4 — 2018-12-05
- 1.0.3 — 2018-12-04
- 1.0.2 — 2018-12-04
- 1.0.1 — 2018-12-04
- 1.0.0 — 2018-12-04

## README

# redux-action-type


Tiny library for using js/ts classes as action creators

```javascript

// Just extends action class and set static 
// field to instance field on initialization
@Action()
class MyAction {
	/**
	* Static type field which will be converted to property on new MyAction()
	*/
	static type = 'type'
}

// somewhere in reducer file
// if typescriot there you can:
// action: TypedAction<T>
const myReducer = (state, action) => {
	switch(action.type) {
		case MyAction.type: {
			// do something
		}
		// ...
	}
}

```

Also because redux does't support nothing but object in dispatch by default there is *reduxActionTypeMiddleware* - just converts class instances to plain object to overpass it

```javascript
import { reduxActionTypeMiddleware } from 'redux-action-type'
// apply mw to your store to use classes
createStore(reducer, applyMiddleware(reduxActionTypeMiddleware))
```

Also for typescript. Lib has redefinition of redux dispatch that allows to pass anything in dispatch ( because with cannot track fields added dynamically so it's only way to overpass it )

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