babel-plugin-redux-action-matching
Last updated 3 years ago by ddoronin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-redux-action-matching 
SYNC missed versions from official npm registry.

babel-plugin-redux-action-matching

A babel transformer plugin that compares arrays in switch-case statements by elements, but not by reference.

Installation

npm install babel-plugin-redux-action-matching

.babelrc

{
  "presets": [
    ["es2015", {"modules": false}],
    "stage-2",
    "react"
  ],
  "plugins": [
    "babel-plugin-redux-action-matching"
  ]
}

Usage

import {FETCH_ACCOUNTS, FETCH_TRANSACTIONS} from './actions';
import {FETCHING, SUCCESS, ERROR} from './actions';

function accountsData(state = {}, action) {
	switch ([action.type, action.status]) {
		case [FETCH_ACCOUNTS, FETCHING]:
			return {
				isFetching: true,
				accounts: []
			};

		case [FETCH_ACCOUNTS, SUCCESS]:
			return {
				isFetching: false,
				accounts: action.data
			};

		case [FETCH_ACCOUNTS, ERROR]:
			return {
				isFetching: false,
				accounts: [],
				error: action.error
			};

		default:
			return state;
	}
}

Current Tags

  • 1.0.4                                ...           latest (3 years ago)

5 Versions

  • 1.0.4 [deprecated]           ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 3
Dependencies (11)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |