Ducks Reducer

Combines reducers from redux-ducks modules into a single reducer.
Alternatives To Ducks Reducer
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Immer25,92787,9804,0525 days ago170May 09, 202343mitJavaScript
Create the next immutable state by mutating the current one
Redux Toolkit9,854252,6357 days ago75May 30, 2023279mitTypeScript
The official, opinionated, batteries-included toolset for efficient Redux development
Ducks Modular Redux9,156
2 years ago36JavaScript
A proposal for bundling reducers, action types and actions when using Redux
Rematch8,175210156a year ago76November 09, 202119mitTypeScript
The Redux Framework
Reswift7,446
15521 days ago9January 15, 201847mitSwift
Unidirectional Data Flow in Swift - Inspired by Redux
Redux Ecosystem Links5,201
3 months ago31
A categorized list of Redux-related addons, libraries, and utilities
Connected React Router4,7312,0667107 months ago51July 11, 2022175mitJavaScript
A Redux binding for React Router v4
Store3,98226 years ago8June 07, 201710mitTypeScript
RxJS powered state management for Angular applications, inspired by Redux
Redux Orm2,96582378 months ago70August 11, 2021115mitJavaScript
NOT MAINTAINED – A small, simple and immutable ORM to manage relational data in your Redux store.
Redux Undo2,8556372092 months ago41July 17, 202335mitJavaScript
:recycle: higher order reducer to add undo/redo functionality to redux state containers
Alternatives To Ducks Reducer
Select To Compare


Alternative Project Comparisons
Readme

ducksReducer building status

Combines reducers from redux-ducks modules into a single reducer.

It uses reducers defined as ducks, see ducks-modular-redux (aka isolated modules), and creates a reducer combining their reducers with combineReducers.

Quick Use

Install with npm:

npm install ducks-reducer
import ducksReducer from 'ducks-reducer'

import * as comments from './comments'
import * as posts from './posts'
import * as users from './users'

const reducer = ducksReducer({ comments, posts, users })

// ...do your stuff...

const store = createStore(reducer, preloadedState, enhancer)

// ...do your stuff...

ducksReducer(ducks)

It creates a reducer with combineReducers with all the reducers of the given reducers.

By default, it assumes that ducks are esModules and it looks for the default property which is suposed to be the reducer:

const reducer = ducksReducer({ comments, posts, users })
// ^ this is equivalent to v
const reducer = combineReducers({
  comments: comments.default,
  posts: posts.default,
  users: users.default,
})

If default is not found in any duck, then it assumes that it may be an ES5 module. Then it looks for the duck itself, if it is a function, then it is considered the reducer.

const reducer = ducksReducer({ comments, posts, users })
// ^ this is equivalent to v
const reducer = combineReducers({ comments, posts, users })

If the duck does not have a default and the duck itself is not a function, then it assumes that there is no reducer for that duck.

It supports to combine all three kinds of ducks (es6 modules, es5 modules and with no reducer).

const reducer = ducksReducer({ comments, posts, users })
// ^ this is equivalent to v
const reducer = combineReducers({
  comments: comments.default, // it was es6 module
  posts: posts,               // it was es5 module
                              // users had no reducer
})

See also

ducks-middleware to compose ducks middlewares.

import ducksReducer from 'ducks-reducer'
import ducksMiddleware from 'ducks-middleware'

import * as comments from './comments'
import * as posts from './posts'
import * as users from './users'

const ducks = { comments, posts, users }
const reducer = ducksReducer(ducks)
const middleware = ducksMiddleware(ducks)

// ...do your stuff...

const store = createStore(
  reducer, 
  preloadedState, 
  applyMiddleware(middleware)
)

// ...do your stuff...
Popular Reducer Projects
Popular Redux Projects
Popular User Interface Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Redux
Reducer