@aappddeevv/dynamics-client-ui
Version:
## What is it? A library to help you create great dynamics applications.
26 lines (25 loc) • 1.66 kB
TypeScript
/** Functions to combine reducers but provide a 3rd arguent, the overall state. */
import { Reducer, AnyAction } from "redux";
/** A reducer that takes injected values as a third argument. */
export declare type Reducer3<LS> = (ls: LS, a: AnyAction, inj: Record<string, any>) => LS;
/**
* A combineReducers replacement that adds additional arguments
* to the reduction call to inject different values a reducer
* might need, read-only, from other parts of the tree. Reducer
* order calling is not specified. The overall state is included under
* the key "_root_". The
* injectables can be thought of as "selectors" that take the global state.
* You need this type of combiner like this when you have a large set of state
* split up into smaller slices but the smaller slices have
* dependencies on other parts of the state, hopefully, small dependences :-)
*
* @template S Combined state object type.
* @param reducers Reducer object. Each key with a function is included in a final reducer.
* These reducers must take three arguments (local state, action, global state).
* @param injectables Key-Functions/values. All functions are called with the overall state
* and current action. The results are attached to an object under their original keys.
* Non-function values are attached directly.
* Ensure that the keys from each injectable do not collide.
* @param rootName The name of the root state added to the third argument automatically.
*/
export declare function combineReducers<S>(reducers: Record<string, Reducer3<any>>, injectables?: Record<string, Reducer<S> | any>, rootName?: string): Reducer<S & Record<string, any>>;