Socket
Book a DemoInstallSign in
Socket

redux-chain

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-chain

Chain multiple actions in a single dispatch call

0.0.4
latest
Source
npmnpm
Version published
Weekly downloads
23
-28.12%
Maintainers
1
Weekly downloads
 
Created
Source

redux-chain

Redux-chain allows you to dispatch multiple actions calls using a single dispatch call.

import { chain } from 'redux-chain'
dispatch(chain(
	signIn(),
	clickOnButton()
	signOut(),
));

Installation

Download

npm install --save redux-chain

Build

npm run build

Installation & Usage

Import & add the middleware to your Redux store

import { createStore, applyMiddleware } from 'redux';
import { chainMiddleware } from 'redux-chain';
import rootReducer from './reducers/index';

const store = createStore(
  rootReducer,
  applyMiddleware(chainMiddleware)
);

To enable thunk actions (or other useful middleware), simply apply redux-chain before other middleware.

import { createStore, applyMiddleware } from 'redux';
import { chainMiddleware } from 'redux-chain';
import thunk from 'redux-thunk';
import rootReducer from './reducers/index';

const middleware = [chainMiddleware, thunk]; // not: [thunk, chainMiddleware]

const store = createStore(
  rootReducer,
  applyMiddleware(middleware)
);

Do more with less

I love to combine redux-chain with novux (github.com/neednova/novux), a tool that helps declare state changes simply, clearly and quickly.

import { chain } from 'redux-chain'
import { update, reset } from 'novux'

const todos = [1, 2];

dispatch(chain(
	update('todos', 'Add a todo', {
		todos: todos.push(3);
	}),
	reset('todos', 'Reset todos', {
		reset: ['todos'],
	}),
));

Keywords

nova

FAQs

Package last updated on 13 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.