JSPM

redux-dynamic-modules-observable

5.2.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 374
  • Score
    100M100P100Q87662F
  • License MIT

Observable Extension for redux-dynamic-modules

Package Exports

  • redux-dynamic-modules-observable

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-dynamic-modules-observable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Usage with redux-observable

You can use redux-dynamic-modules alongside redux-observable so that you can add/remove Epics along with your modules.

To use

  • npm install redux-dynamic-modules-observable
  • Add the observable extension to the createStore call
import { createStore, IModuleStore } from "redux-dynamic-modules";
import { getObservableExtension } from "redux-dynamic-modules-observable";
import { getUsersModule } from "./usersModule";

const store: IModuleStore<IState> = createStore(
    {
        initialState: { /** initial state */ },
        enhancers: [ /** enhancers to include */ ], 
        extensions: [getObservableExtension()],
    },
    getUsersModule()
    /* ...any additional modules */
);
  • Add the epics property to your modules, and specify a list of observables to run
import { IEpicModule } from "redux-dynamic-modules-observable";

export function getUsersModule(): IEpicModule<IUserState> {
    return {
        id: "users-module",
        reducerMap: {
            users: usersReducer,
        },
        epics: [usersEpic],
        // Actions to fire when this module is added/removed
        // initialActions: [],
        // finalActions: [],
    };
}