@redux-eggs/core
v3.0.0-alpha.4
Published
This package includes logic for creating Redux store and adding/removing/counting `eggs`.
Downloads
8,742
Readme
Redux Eggs Core
This package includes logic for creating Redux store and adding/removing/counting eggs
.
Contents:
Intro
The main function that does all the work is called buildStore.
Most likely you will never need to use this function directly, since Redux Eggs already includes packages like @redux-eggs/redux and @redux-eggs/redux-toolkit, which are a high-level API for creating Redux store using Redux or Redux Toolkit, respectively.
Installation:
If you are using Yarn, run
yarn add @redux-eggs/core
If you are using NPM, run
npm install --save @redux-eggs/core
API Reference
buildStore(storeCreator, combiner, composeMiddlewares, [extensions])
This is a wrapper that allows you to create Redux store with the necessary methods to add/remove/count eggs
. It
returns an object with Redux store
and some methods from Redux Eggs.
Arguments:
storeCreator(reducer, middlewareEnhancer, enhancersFromExtensions, middlewaresFromExtensions)
reducer
- a root reducer that is required to dynamically add/remove reducers.middlewareEnhancer
- a root middleware that is required to dynamically add/remove middleware.enhancersFromExtensions
- an array of enhancers fromExtensions
.middlewaresFromExtensions
- an array of middlewares fromExtensions
.
combiner(reducersMap)
A function for combining reducers. Default: combineReducers.
composeMiddlewares(...functions)
A function for composing middlewares. Default: compose.
extensions
An array of Extensions
. This is an optional argument.
Example:
import { buildStore } from '@redux-eggs/core'
import * as Redux from 'redux'
const store = buildStore(reducer => Redux.createStore(reducer), Redux.combineReducers, Redux.compose)
REDUCE_ACTION_TYPE
Redux Action Type. Redux action with this type is triggered after a successful addition or removal of reducers. This is an internal action, it is necessary for the correct state update after adding or removing reducers.
Example:
import { REDUCE_ACTION_TYPE } from '@redux-eggs/core'
const myMiddleware = store => next => action => {
if (action.type === REDUCE_ACTION_TYPE) {
console.log(action) // -> { type: '@@eggs/reduce' }
}
return next(action)
}
getCounter([equalityCheck], [keepCheck])
This function will be useful for developers of extensions for Redux Eggs. All details you can find here.