1.5.10 • Published 4 months ago

@mihanizm56/redux-core-modules v1.5.10

Weekly downloads
10
License
MIT
Repository
github
Last release
4 months ago

@mihanizm56/redux-core-modules

Sollution for redux-store and root modules implementation

Benefits:

  • Gives an opportunity to initialize the redux store with root modules 'in a one string'
  • Includes the main redux-saga managers
  • Exports all root reducers and watcher-sagas to be implemeted into your own store
  • Exports all necessary typings and default action types (Action and BaseAction)
  • Has batching mode in the store initialization (redux-batched-actions library)
  • Provides redirect-manager-module based on the Router5 to be able to navigate in your worker sagas
  • Gives injecting reducers and sagas mechanizm

Examples of usage

installation

npm install @mihanizm56/redux-core-modules

implementing store in regular App

import { createAppStore } from '@mihanizm56/redux-core-modules';

const ROOT_ELEMENT = document.getElementById('root');

const router: any = configureRouter();

const store = createAppStore({ router });

router.setDependencies({
  store,
});

router.start(() => {
  ReactDOM.render(
    <Provider store={store}>
      <App router={router} />
    </Provider>,
    ROOT_ELEMENT,
  );
});

Example usage of form-manager-module

import { fetchFormManagerSagaAction } from '@mihanizm56/redux-core-modules';

submitForm = (formValues: SignatureRenewalFormDataType) => {
    const {
        formLoadingStart,
        formLoadingStop,
        submitForm,
        formSaveAction,
    } = this.props;

    const formManagerSubmitOptions = {
        resetInitialDataAction: formSaveAction,
        formValues,
        loadingStartAction: formLoadingStart,
        loadingStopAction: formLoadingStop,
        formRequest: signatureRenewalFormSubmitRequest,
        showNotification: true,
        withoutFormattingError: true,
        redirectSuccessActionParams: {
            pathName: 'home.supplier-card',
        },
    };

    this.props.dispatch(fetchFormManagerSagaAction(formManagerSubmitOptions));
  };

Example usage of init-loader-manager

import { initLoadManagerActionSaga } from '@mihanizm56/redux-core-modules';

const loadDataConfig = {
  requestConfigList: [
    {
      request: initSupplierInfoRequest,
      isDataCritical: false,
      showErrorNotification: true,
      showSuccessNotification: false,
      requestExtraDataHandlerOptions: [
        {
          fieldName: 'supplierName',
          action: setSupplierNameAction,
        },
        {
          fieldName: 'contactInfo',
          action: setContactInfoAction,
        },
        {
          fieldName: 'warehouses',
          action: setWarehousesAction,
        },
      ],
    },
  ],
};

this.props.dispatch(initLoadManagerActionSaga(loadDataConfig));

Example usage redirect-manager-module

import { redirectManagerWorkerSaga } from '@mihanizm56/redux-core-modules';

this.props.dispatch(redirectManagerSagaAction({
  pathName: 'pathName',
  params: {
    foo:'bar'
  },
  actionAfterRedirect: setModalAction,
  actionAfterRedirectParams: {
    status: 'success',
    text: 'some message',
    id: uniqueId('notification_'),
  },
  reload: true;
}));

Example usage ui-module

import { 
    startPageLoadingAction,
    stopPageLoadingAction,
    setErrorsMapAction,
    setAppErrorAction,
    removeAppErrorAction
} from '@mihanizm56/redux-core-modules';

this.props.dispatch(startPageLoadingAction);

this.props.dispatch(stopPageLoadingAction);

this.props.dispatch(setAppErrorAction);

this.props.dispatch(removeAppErrorAction);

this.props.dispatch(setErrorsMapAction({
    TIMEOUT_ERROR: 'timeout error';
    REQUEST_DEFAULT_ERROR: 'sorry the request in invalid';
    FORBIDDEN: 'sorry the response is forbidden'
}));

Example of import modules into your own root reducer

// root-reducers.ts
import {
    notificationsModuleReducer,
    uiModuleReducer
} from '@mihanizm56/redux-core-modules';

const rootReducers = {
  notificationsModuleReducer,
  uiModuleReducer,
};

Example of import modules into your own root-saga

// root-saga.ts
import { all, fork } from 'redux-saga/effects';
import { Router } from 'router5';
import { Dispatch } from 'redux';
import { 
    formManagerWatcherSaga,
    initLoadManagerWatcherSaga,
    requestExtraDataHandlerWatcherSaga,
    redirectManagerWatcherSaga 
} from '@mihanizm56/redux-core-modules';

type RootSagaParams = {
  router: Router;
  dispatch: Dispatch;
};

function* rootSaga({ router, dispatch }: RootSagaParams) {
  yield all([
    fork(formManagerWatcherSaga),
    fork(initLoadManagerWatcherSaga),
    fork(requestExtraDataHandlerWatcherSaga),
    fork(redirectManagerWatcherSaga, { router, dispatch }),
  ]);
}
1.6.0-beta.10

4 months ago

1.6.0-beta.9

4 months ago

1.6.0-beta.8

1 year ago

1.6.0-beta.6

2 years ago

1.6.0-beta.7

1 year ago

1.6.0-beta.5

2 years ago

1.6.0-beta.3

2 years ago

1.5.9

2 years ago

1.5.10

2 years ago

1.6.0-beta.1

2 years ago

1.6.0-beta.2

2 years ago

1.5.9-beta.3

2 years ago

1.5.9-beta.2

2 years ago

1.5.8

2 years ago

1.5.8-beta.3

2 years ago

1.5.8-beta.1

2 years ago

1.5.8-beta.2

2 years ago

1.5.9-beta.1

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.6-beta.1

2 years ago

1.5.5-beta.1

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.4-beta.1

2 years ago

1.5.4-beta.2

2 years ago

1.5.4-beta.3

2 years ago

1.5.4-beta.4

2 years ago

1.5.3-beta.1

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.5.0-beta.1

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.0-beta.2

2 years ago

1.4.0-beta.1

3 years ago

1.4.2-beta.1

2 years ago

1.4.2-beta.2

2 years ago

1.3.6-beta.1

3 years ago

1.3.6-alpha.1

3 years ago

1.3.5

3 years ago

1.3.5-beta.2

3 years ago

1.3.4

3 years ago

1.3.5-beta.1

3 years ago

1.3.4-beta.2

3 years ago

1.3.4-beta.1

3 years ago

1.3.3

3 years ago

1.3.3-beta.3

3 years ago

1.3.3-beta.1

3 years ago

1.3.3-beta.2

3 years ago

1.3.2

3 years ago

1.3.2-beta.1

3 years ago

1.3.1

3 years ago

1.3.1-beta.1

3 years ago

1.3.0

3 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3-beta.10

4 years ago

1.2.3-beta.11

4 years ago

1.2.3-beta.9

4 years ago

1.2.3-beta.8

4 years ago

1.2.3-beta.5

4 years ago

1.2.3-beta.4

4 years ago

1.2.3-beta.3

4 years ago

1.2.3-beta.2

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0-beta-2

4 years ago

1.2.0-beta-1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.0.2

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago