# redux-reactors

> A small library for creating action/reducer combinations.

Latest version **1.0.3** (published 2017-05-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-05-05 |
| First published | 2017-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Giancarlo Anemone |
| Maintainers | ganemone |

## Links

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

## Recent versions

- 1.0.3 (latest) — 2017-05-05
- 1.0.2 — 2017-05-01
- 1.0.1 — 2017-05-01
- 1.0.0 — 2017-05-01

## README

# redux-reactors

A small library (~20 loc) for creating action/reducer combinations, also known as reactors.

[![build status](https://travis-ci.org/ganemone/redux-reactors.svg?branch=master)](https://travis-ci.org/ganemone/redux-reactors)
[![npm version](https://img.shields.io/npm/v/redux-reactors.svg)](https://www.npmjs.com/package/redux-reactors)

## Quickstart

### Install the library
```sh
$ npm install redux-reactors --save
```

### Add the store enhancer
```javascript
import {reactorEnhancer} from 'redux-reactors';
import {createStore, compose} from 'redux';
// ...
const store = createStore(reducer, initialState, compose(reactorEnhancer, ...otherEnhancers));
```

### Create reactors
```javascript
import {createReactor} from 'redux-reactors';
export const incrementReactor = createReactor('INCREMENT', (state, action) => {
  return Object.assign({}, {
    counter: state.counter + action.payload,
    state,
  });
});
```

### Use reactors in your components
```javascript
import {incrementReactor} from './my-reactors';
import {connect} from 'react-redux';

function MyComponent(props) {
  const {increment, counter} = props;
  return (
    <div>
      <div>The count is {counter}</div>
      <button onClick={() => increment(1)}>Increment by one</button>
      <button onClick={() => increment(2)}>Increment by two</button>
    </div>
  );
}

const mapStateToProps = (state) => {
  return {
    counter: state.counter,
  };
};

// Since createReactor returns an action creator,
// you can use it easily with mapDispatchToProps
const mapDispatchToProps = {
  increment: incrementReactor,
};

export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);
```

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