ReducerInjector
class ReducerInjector
An object that handles injection of reducers into the Redux store that is managed by an ObjectiveStore.
This can be used when middleware or another part of the application also needs to handle injection. For example, this should be used when Redux-Injectors is being used with Objective Redux.
Examples
import { ReducerInjector, ObjectiveStore } from 'objective-redux';
import { createInjectorsEnhancer } from 'redux-injectors';
import { initialState, initialReducers } from './elsewhere';
const injector = new ReducerInjector(initialReducers);
const createReducer = injector.getReducerCreationFn();
const runSaga = injector.getRunSagaFn();
const middleware = [
createInjectorsEnhancer({ createReducer, runSaga }),
];
const objectiveStore = new ObjectiveStore({
reducer,
initialState,
middleware,
injector,
});
constructor
public constructor(initialReducers: Record<string, any> = {}): ReducerInjector
Creates an injector instance.
Parameters
Returns
Examples
const injector = new ReducerInjector({
MyReducer: reducerOne,
});
getReducerCreationFn
public getReducerCreationFn(): CreateReducerFn
A function that can be used to get add additional reducers to the store.
Returns
internal to Objective Redux, resulting in a final, combined reducer.
Examples
const initialReducers = {
MyInitialReducer: reducerOne,
};
const injector = new ReducerInjector(initialReducers);
const reducerCreationFn = injector.getReducerCreationFn();
const objectiveStore = new ObjectiveStore({
injector,
});
const nextReducer = reducerCreationFn({
MyInitialReducer: reducerTwo,
});
objectiveStore.replaceReducer(nextReducer);
getSagaRunningFn
public getSagaRunningFn(): RunSagaFn
Returns
setGetObjectiveReduxReducers
public setGetObjectiveReduxReducers(getObjectiveReduxReducers: () => Record<string, Reducer>): void
This function should not be called directly.
Sets the get function for retrieving the reducers internal to Objective Redux.
Parameters
This only be used by the ObjectiveStore and should not be called directly.
Returns
Examples
// Do not use this function directly!
setSagaRunningFn
public setSagaRunningFn(sagaRunningFn: any): void
This function should not be called directly.
Sets the get function for running a Saga.
Parameters
Returns
Examples
// Do not use this function directly!