Form-manager-module - helps to work with the form submission
Init-load-manager-module - helps to get data when page is rendering
Redirect-manager-module - helps to navigate in redux-saga worker saga
Request-extra-data-handler-module - helps to make different actions from response data
UI-module - helps with working in the whole app ui-data
Form-manager-module - gets options and make request and handle different operations:
re-save form data (necessary for react-final-form) before call the request and set new data
format form data before to insert to the request
start and stops form loading state
call error action (of array of actions)
call success action (of array of actions)
trigger notifications actions on success and error
send data (formatted of not) to the Request-extra-data-handler-module to make some operations with splitted data from response
trigger success or error router redirections
trigger scroll to error fields (if you provide scroll util)
Example:
import{fetchFormManagerSagaAction}from'@wildberries/redux-core-modules';constformManagerSubmitOptions: FormManagerType={formValues: {foo:'bar'},loadingStartAction: ()=>({type:'loading start'}),loadingStopAction: ()=>({type:'loading stop'}),formValuesFormatter: (data)=>({'baz':data.foo}),formRequest: fetch('http://example.com'),formSuccessAction: (payload)=>({type:'some example success action', payload }),setErrorAction: (payload)=>({type:'some example error action', payload }),resetInitialDataAction: (payload)=>({type:'action to re-save form data', payload }),showNotification: true,redirectSuccessActionParams: {pathName: 'some.path',},scrollToErrorOnField:()=>{// scroll here},// if you need data to be formatted before sended to scrollToErrorOnFieldscrollFormErrorsFormatterOnSuccess: (data)=>{// responseData.data will be provided from response},scrollFormErrorsFormatterOnError: ()=>{// {errorText, additionalErrors} will be provided from response}};store.dispatch(fetchFormManagerSagaAction(formManagerSubmitOptions));
Init-load-manager-module - has the separate config for each request and makes operations:
start and stop form loading state (not in each request but in the whole action)
format request data before and after the request
get the options (or not) and calls the request
trigger notifications actions on success and error
call error action (of array of actions)
call success action (of array of actions)
send data (formatted of not) to the Request-extra-data-handler-module to make some operations with splitted data from response
trigger success or error router redirections
ability to use batching (in JSON-RPC protocol)
cancelling the request if not responded
on every request can make a decision to refetch data or not by providing function or redux-selector (or an array of them)
Redirect-manager-module - simple options-provider to the router.navigate method from router5:
redirects to internal routes
redirects to external routes (for example if you are using microservice architecture and you stream-app doesn't know about external routes)
provides actions:
import{redirectManagerSagaAction,redirectToPlatformRouteManagerSagaAction}from'@wildberries/redux-core-modules';store.dispatch(redirectManagerSagaAction({pathName: 'route.path.name';
params: {foo:'bar'};
actionAfterRedirect: (payload)=>({type:'action that will be called after redirect', payload })
actionAfterRedirectParams: {id: 'test_id'};}));'there is no differences between action signatures - they are actually go to the one watcher-saga''but to show exactly where do you want to redirect - we provide this method'store.dispatch(redirectToPlatformRouteManagerSagaAction({pathName: 'route.path.name';
params: {foo:'bar'};
actionAfterRedirect: (payload)=>({type:'action that will be called after redirect', payload })
actionAfterRedirectParams: {id: 'test_id'};}));
Request-extra-data-handler-module:
gets the data and array of options to process this data with redux-actions
provides actions:
import{requestExtraDataHandlerActionSaga,RequestExtraDataHandlerActionSagaType}from'@wildberries/redux-core-modules';store.dispatch(requestExtraDataHandlerActionSaga({data: {field1: {foo: 'bar'},field2: {someOption: [{foo:'bar'}]}},options: [{fieldName: 'field1';action: (payload)=>({type:'action that will be called with the field1 data', payload })},{fieldName: 'field2';action: (payload)=>({type:'action that will be called with the field2 data', payload })},]}));
requestErrorHandlerProcess util:
gets the request
provide the validation for the request
dispatches an action or an array of actions if the response is invalid
options for that feature exist in Form-manager-module and in Init-load-manager-module
import{injectAsyncReducer}from'@wildberries/redux-core-modules';injectAsyncReducer({
store,'-- pure store object'name: 'registrationFormStorage','-- reducer name'reducer: registrationFormStorage,'-- reducer instance'});
inject sagas:
import{injectAsyncSaga}from'@wildberries/redux-core-modules';injectAsyncSaga({
store,'-- pure store object'name: 'downloadContractOfferWatcherSaga','-- saga name'saga: downloadContractOfferWatcherSaga,'-- saga instance'});
inject sagas and reducers with config that is the same as InjectorConfig for ReduxStoreLoader:
import{runInjectorConfig}from'@wildberries/redux-core-modules';// enable SSR mode // and enable manualSagaStart - that means not to run saga inside createAppStore functionconststore=createAppStore({manualSagaStart: true,});constsagaRunner=store.sagaMiddleware.run(store.rootSaga);conststoreInjectConfig={/* here place the config */}runInjectorConfig({ store, storeInjectConfig });
remove sagas:
import{removeAsyncSaga}from'@wildberries/redux-core-modules';removeAsyncSaga({
store,'-- pure store object'name: 'downloadContractOfferWatcherSaga','-- saga name'});
remove reducers:
Warning - please be accurate with this. You can lose your necessary data !
import{removeAsyncReducer}from'@wildberries/redux-core-modules';removeAsyncReducer({
store,'-- pure store object'name: 'registrationFormStorage','-- saga name'});
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.