How to use redux-dynamic-modules-core - 3 common examples

To help you get started, we’ve selected a few redux-dynamic-modules-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / redux-dynamic-modules / packages / widgets-example / src / App.js View on Github external
constructor(props) {
        super(props);

        // define the initial state where none of the widgets are visible
        this.state = {
            hackerNews: false,
            weather: false,
        };

        /**
         * configure the store and load the thunk and saga extension
         * The extensions are optional and you can choose extension based on the middleware you use
         * You can also build your own extensions for any other middleware e.g. redux-observable
         */
        this.store = createStore({
            enhancements: [offline(offlineConfig)],
            extensions: [getThunkExtension(), getSagaExtension()],
        });
    }
github microsoft / redux-dynamic-modules / packages / redux-dynamic-modules-observable / src / EpicManager.ts View on Github external
export function getEpicManager(
    epicMiddleware: EpicMiddleware
): IEpicManager {
    let runningEpics: { [epicKey: string]: IEpicWrapper } = {};
    // @ts-ignore
    let epicRefCounter = getObjectRefCounter();

    return {
        /**
         * Dynamically add epics.
         *
         * We should consider these potential problem:
         * * Epic could add repeatedly
         * * Epic could as a dependency of two or more modules
         * * Module hot load. React-hot-loader will rerender your react root
         * component which means it will invoke all of your logic again. So this is
         * minor worry.
         */
        add(epics: Epic[] = []) {
            epics.forEach(epic => {
                const epicKey = epic.toString();
                // Check if epic already exists
github microsoft / redux-dynamic-modules / packages / redux-dynamic-modules-saga / src / SagaManager.ts View on Github external
export function getSagaManager(
    sagaMiddleware: SagaMiddleware
): IItemManager> {
    const tasks = getMap, Task>(sagaEquals);

    return {
        getItems: (): ISagaRegistration[] => [...tasks.keys],
        add: (sagas: ISagaRegistration[]) => {
            if (!sagas) {
                return;
            }
            sagas.forEach(saga => {
                if (saga && !tasks.get(saga)) {
                    tasks.add(saga, runSaga(sagaMiddleware, saga));
                }
            });
        },
        remove: (sagas: ISagaRegistration[]) => {
            if (!sagas) {
                return;

redux-dynamic-modules-core

Modularize the redux app by dynamically loading reducers, state and sagas

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis