Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ciamiz committed Mar 28, 2018
1 parent bbbf70f commit cc9b7b5
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,42 @@

[![Build Status](https://travis-ci.org/0xc14m1z/redux-reducer-generator.svg?branch=master)](https://travis-ci.org/0xc14m1z/redux-reducer-generator) [![Coverage Status](https://coveralls.io/repos/github/0xc14m1z/redux-reducer-generator/badge.svg?branch=master)](https://coveralls.io/github/0xc14m1z/redux-reducer-generator?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/71529a56fad691ed2c10/maintainability)](https://codeclimate.com/github/0xc14m1z/redux-reducer-generator/maintainability)

## DO NOT USE THIS PACKAGE, IT IS STILL IN DEVELOPMENT

## how to install

```
$ npm install --save redux-reducer-generator
```

## how to use it

The goal of this package is to shorten and lean the switch statement for
redux reducers, replacing it with a map between action types and methods that
handles those actions.

```js

import reducer from "redux-reducer-generator"
// or var reducer = require("redux-reducer-generator")

const initialState = {
loading: false,
errors: false
}

const SHOW_LOADER = "SHOW_LOADER"
const HIDE_LOADER = "HIDE_LOADER"

const showLoader = (state, action) =>
({ ...state, loading: true })

const hideLoader = (state, action) =>
({ ...state, loading: false })

const map = {
[SHOW_LOADER]: showLoader,
[HIDE_LOADER]: hideLoader
}

const loadingReducer = reducer(initialState, map)

```

0 comments on commit cc9b7b5

Please sign in to comment.