Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.
This repository was archived by the owner on Jul 28, 2022. It is now read-only.

Is it possible to dynamically load my reducers #7

@vvdwivedi

Description

@vvdwivedi

Right now, the way I have to compose reducers require to provide all reducers at once and then store is created. Is it possible that once I load a component, I load the reducer, saga for that particular component? Something like this where I inject a couple of reducers and then load others as they come:

import { combineReducers } from 'redux-immutable';
import appReducer from './containers/app-root/app.reducer';
import homeReducer from './containers/home/home.reducer';
/**
 * Creates the main reducer with the asynchronously loaded ones
 */
export default function createReducer(asyncReducers?) {
  return combineReducers({
    app: appReducer,
    home: homeReducer,
    ...asyncReducers,
  });
}

This createReducer can then be used while creating my store like this:

const store = createStore(
    createReducer(),
    immutable.fromJS(initialState),
    composeEnhancers(...enhancers)
  );

Typically, while routing using ion-router I would like to specify the reducer and saga (or thunk) for a route.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions