# classy_redux

> Uses OOP to simplify Redux reducer logic

Latest version **1.0.0** (published 2016-11-24) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install classy_redux
pnpm add classy_redux
yarn add classy_redux
bun add classy_redux
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-11-24 |
| First published | 2016-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Jeremy Walker |
| Maintainers | machineghost |
| Keywords | redux |

## Links

- npm: https://www.npmjs.com/package/classy_redux
- Repository: https://github.com/machineghost/Classy-Redux
- Homepage: https://github.com/machineghost/Classy-Redux#readme
- Issues: https://github.com/machineghost/Classy-Redux/issues
- npm.io page: https://npm.io/package/classy_redux

## Dependencies (2)

- [redux](https://npm.io/package/redux.md) ^3.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.2

## Recent versions

- 1.0.0 (latest) — 2016-11-24

## README

# Classy-Redux
A Class-Based System for Creating Redux Reducers

Convert:

    const reducer = function(state={}, action) {
         function addFoo({id}, state) {
             return {...state, foo: id};
         }
         function addBar({id}, state) {
             return {...state, bar: id};
         }
         switch(action.type) {
             case 'ADD_FOO': return addFoo(action, state);
             case 'ADD_BAR': return addBar(action, state);
         }
    }
    
In to:

    class YourReducerBuilder extends ReducerBuilder {
        addFoo({id}, state) {
            return {...state, foo: id};
        }
        addBar({id}, state) {
            return {...state, bar: id};
        }
    }
    const {reducer} = new YourReducerBuilder();
    
Or, if you're not in to that whole ES6 thing ...

    function YourReducerBuilder () {};
    YourReducerBuilder.prototype.addFoo = function(action, state) {
        return Object.assign({}, state, {foo: action.id});
    }
    YourReducerBuilder.prototype.addBar = function(action, state) {
        return Object.assign({}, state, {bar: action.id});
    }
    YourResourceBuilder.prototype = new ReducerBuilder();
    const reducer = new YourReducerBuilder().reducer;


Easily combine multiple resource builders and your middleware (in any order) to create a store:

    const {store} = new StoreBuilder(fooBuilder, thunk, barBuilder, bazBuilder, window.devToolsExtension);

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