| 1 | import { DynamicMiddlewareInstance, TSHelpersExtractDispatchExtensions, MiddlewareApiConfig, GetState, GetDispatch } from '@reduxjs/toolkit';
|
|---|
| 2 | export * from '@reduxjs/toolkit';
|
|---|
| 3 | import { Context } from 'react';
|
|---|
| 4 | import { ReactReduxContextValue } from 'react-redux';
|
|---|
| 5 | import { Dispatch, UnknownAction, Action, Middleware } from 'redux';
|
|---|
| 6 |
|
|---|
| 7 | type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
|---|
| 8 | type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
|---|
| 9 | <Middlewares extends [
|
|---|
| 10 | Middleware<any, State, DispatchType>,
|
|---|
| 11 | ...Middleware<any, State, DispatchType>[]
|
|---|
| 12 | ]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
|---|
| 13 | withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
|---|
| 14 | };
|
|---|
| 15 | type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
|---|
| 16 | type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
|---|
| 17 | createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|---|
| 18 | createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
|---|
| 19 | };
|
|---|
| 20 | declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
|---|
| 21 |
|
|---|
| 22 | export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
|---|