redux-actions
Flux Standard Action utlities for Redux
Last updated 6 years ago by timche .
MIT · Repository · Bugs · Original npm
$ cnpm install redux-actions 
SYNC missed versions from official npm registry.

redux-actions

Build Status codecov npm npm

Flux Standard Action utilities for Redux

Table of Contents

Getting Started

Installation

$ npm install --save redux-actions

or

$ yarn add redux-actions

The npm package provides a CommonJS build for use in Node.js, and with bundlers like Webpack and Browserify. It also includes an ES modules build that works well with Rollup and Webpack2's tree-shaking.

The UMD build exports a global called window.ReduxActions if you add it to your page via a <script> tag. We don’t recommend UMD builds for any serious application, as most of the libraries complementary to Redux are only available on npm.

Usage

import { createActions, handleActions, combineActions } from 'redux-actions';

const defaultState = { counter: 10 };

const { increment, decrement } = createActions({
  INCREMENT: (amount = 1) => ({ amount }),
  DECREMENT: (amount = 1) => ({ amount: -amount })
});

const reducer = handleActions(
  {
    [combineActions(increment, decrement)]: (
      state,
      { payload: { amount } }
    ) => {
      return { ...state, counter: state.counter + amount };
    }
  },
  defaultState
);

export default reducer;

See the full API documentation.

Documentation

Current Tags

  • 2.6.5                                ...           latest (6 years ago)
  • 0.8.0-alpha                                ...           prerelease (10 years ago)

2 Versions

  • 0.8.0-alpha                                ...           10 years ago
  • 2.6.5                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org