@malfaitrobin/redux-one-of-types

0.0.1 • Public • Published

oneOfType npm version npm downloads

Handle multiple types with the same reducer function.

Installation

With yarn:

yarn install @malfaitrobin/redux-one-of-types

With npm:

npm install --save @malfaitrobin/redux-one-of-types

Usage

import { createReducerCreator } from "@malfaitrobin/redux";
import { oneOfTypesMiddleware, oneOf } from "@malfaitrobin/redux-one-of-types";

const createReducer = createReducerCreator(
  oneOfTypesMiddleware /* ...other middleware */
);

const defaultState = {
  value: 0
};

const reducer = createReducer(
  {
    // This method will be executed whenever an action with { type: 'FOO' } or { type: 'BAR' } is dispatched.
    [oneOf("FOO", "BAR")]: (state, action) => {
      return state;
    }
  },
  defaultState
);

Readme

Keywords

none

Package Sidebar

Install

npm i @malfaitrobin/redux-one-of-types

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • malfaitrobin