import { Reducer, UnknownAction, EnhancedStore } from "@reduxjs/toolkit"; import { Provider } from "react-redux"; import { SubAppFeatureFactory, SubAppFeature, FeatureDecorator } from "@xarc/subapp"; export * as Redux from "@reduxjs/toolkit"; export { combineReducers, configureStore, Reducer, bindActionCreators, } from "@reduxjs/toolkit"; export * as ReactRedux from "react-redux"; export { connect, Provider, batch, useSelector, useDispatch, useStore, } from "react-redux"; /** * Redux decorator params */ export type ReduxDecoratorParams = { /** initial state */ initialState: unknown; /** reducers */ reducers: unknown; }; /** * Redux decorator result */ export type ReduxDecoratorResult = { /** store if the decorator created one */ store: EnhancedStore; }; /** * Redux feature decorator */ export type ReduxFeatureDecorator = FeatureDecorator; /** * Options for redux feature */ export type ReduxFeatureOptions = { /** * add redux decorators to the redux feature. * * decorators: `@xarc/react-redux-observable` */ decorators?: ReduxFeatureDecorator[]; /** * The React module. * * This is needed for the redux feature to wrap subapp's component inside * the Redux Provider component. */ React: Partial<{ createElement: any; }>; /** * Configure the redux store to use * * - `true` - share with an automatically provided global store * - `false` - internal private store available to the subapp instance only * - string - name a store for sharing - other subapps can share the same store * using the name */ shareStore?: string | boolean; /** * specify redux reducer or object of named reducers * * - If it's an object, then it should be an object of named reducers * - If it's `true`, then the subapp module should export the named reducers as `reduxReducers` * - If it's a function, then it's used as the reducer */ reducers?: Reducer | Record> | boolean; /** * prepare redux initial state * * @param initialState - when SSR sent initialState used, it will be passed. The client * `prepare` can just return `{initialState}` as is. * * @returns Promise<{initialState: any}> */ prepare(initialState: any): Promise<{ initialState: any; }>; }; /** * Redux support for a subapp */ export type ReduxFeature = SubAppFeature & { options: ReduxFeatureOptions; wrap: (_: any) => any; Provider: typeof Provider; configureStore: (reducer: Reducer, initialState: any) => EnhancedStore; prepare: any; _store?: EnhancedStore; }; /** * Add support for Redux to a subapp * * @param options - redux feature options * @returns unknown */ export declare function reduxFeature(options: ReduxFeatureOptions): SubAppFeatureFactory;