Socket
Socket
Sign inDemoInstall

combine-section-reducers

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    combine-section-reducers

Combines section reducers


Version published
Weekly downloads
541
increased by9.51%
Maintainers
1
Install size
11.5 kB
Created
Weekly downloads
 

Readme

Source

combineSectionReducers

One of the best ways to create a big reducer.

npm version

Installation

npm install --save combine-section-reducers

What's the section reducers?

Section reducers is the same as reducers but it requires the third argument to get the entire state.
(sectionState, action, state) => newSectionState
It's called a section reducer.
But we had better write it as below not to be confused when we use combineReducers and combineSectionReducers together.
(state, action, entireState) => newState

Usage

The usage of combineSectionReducers is the same as Redux's combineReducers's one.
But you can pass not only normal reducers but also section reducers to it.
Also, the result of combineSectionReducers can be used as not only a normal reducer but also a section reducers.

Example

import { combineReducers } from 'redux'
import combineSectionReducers from 'combine-section-reducers'

// Create a big reducer.
combineSectionReducers({
  a: combineSectionReducers({
    a: sectionReducerA,
    b: sectionReducerB
  }),
  b: combineSectionReducers({
    a: sectionReducerC,
    b: reducerA
  })
})

// Use combineReducers together.
combineReducers({
  a: combineSectionReducers({
    a: combineReducers({
      a: sectionReducerA,
      b: reducerA
    },
    b: combineSectionReducers({
      a: sectionReducerB,
      b: reducerB
    },
  }),
  b: combineReducers({
    a: combineReducers({
      a: sectionReducerC,
      b: reducerC
    },
    b: combineSectionReducers({
      a: sectionReducerD,
      b: reducerD
    },
  }),
})

License

MIT

Keywords

FAQs

Last updated on 02 Jul 2018

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc