# redux-chillout

> Redux utility for prevent boilerplate code

Latest version **2.0.2** (published 2020-10-30) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-10-30 |
| First published | 2019-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alan Saracho |
| Maintainers | alan-saracho |

## Links

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

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^16.13.1
- [redux](https://npm.io/package/redux.md) 4.0.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [react-dom](https://npm.io/package/react-dom.md) ^16.13.1
- [react-redux](https://npm.io/package/react-redux.md) 7.1.3

## Recent versions

- 2.0.2 (latest) — 2020-10-30
- 2.0.1 — 2020-08-02
- 2.0.0 — 2020-08-02
- 1.0.1 — 2019-06-06

## README

# Redux Chillout
Generate actions and reducers based on whatever(transformers).
Designed for remove vanilla redux boilerplate code. 

# Instalation

```javascript
npm install redux-chillout redux@4.0.4 react-redux@7.1.3
```  

Create your chillout file
```javascript
import {generateChillout} from 'redux-chillout';

const [LinkedActions, reducer, Types] = generateChillout({
    fetchValues: null,
    setValue: ['value'],
    addValue: state => ({amount: state.amount + 1}),
    removeValue: (state, action) => ({amount: state.amount - action.amount}),
}, {
    amount: 0 // Initial state
});

export {Types};
export {LinkedActions};
export default reducer;

```

Create store

```javascript
import {createStore as createChilloutStore} from 'redux-chillout';

const store = createChilloutStore(rootReducer);
```

# Linked Actions

It's not necessary to dispatch your actions, because redux-chillout LinkedActions has been linked with your store, so yo can execute it anywhere.

Normal Redux:

```javascript
dispatch(LinkedActions.setValue(0));
dispatch(LinkedActions.removeValue({amount: 10}));
```

Redux Chillout:

```javascript
LinkedActions.setValue(0);
LinkedActions.removeValue({amount: 10});
```


# Transformers

Redux chillout recognize your transformer type and generate an action and a action-reducer based on it.

- **NoopTransformer:**
Create a empty action 

```javascript
fetchValues: null
```

- **ArrayTransformer:**
Use it for setters

```javascript
setValue: ['value'],
setUser: ['name', 'id', 'password'],
```

- **ActionReducerTransformer:** Action Reducer is a small reducer for a simple action. In case of a plain object state, not need the typical spread operator for merge.

```javascript
removeValue: (state, action) => ({/*...state, unnecessary */ amount: state.amount - action.amount}),
```

# Custom Transformers

You can create your own transformers.
```javascript
class MyTransformer = {
    static checkType(transformer, actionType) {
	return transformer === 'clearAll';
    }
    static getActionReducer(transformer, actionType) {
	return (state, action) => ({});
    }
    static getAction(transformer, actionType) {
	return (...params) => ({type: actionType})
    }
}

addTransformer(myTransformer);
console.log(registeredTransformers); // -> show registered transformers
```


# Example App

https://github.com/AlanSaracho/eth-wallet

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