|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | import type { StoreEnhancer } from 'redux'
|
|---|
| 2 | import type { AutoBatchOptions } from './autoBatchEnhancer'
|
|---|
| 3 | import { autoBatchEnhancer } from './autoBatchEnhancer'
|
|---|
| 4 | import { Tuple } from './utils'
|
|---|
| 5 | import type { Middlewares } from './configureStore'
|
|---|
| 6 | import type { ExtractDispatchExtensions } from './tsHelpers'
|
|---|
| 7 |
|
|---|
| 8 | type GetDefaultEnhancersOptions = {
|
|---|
| 9 | autoBatch?: boolean | AutoBatchOptions
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | export type GetDefaultEnhancers<M extends Middlewares<any>> = (
|
|---|
| 13 | options?: GetDefaultEnhancersOptions,
|
|---|
| 14 | ) => Tuple<[StoreEnhancer<{ dispatch: ExtractDispatchExtensions<M> }>]>
|
|---|
| 15 |
|
|---|
| 16 | export const buildGetDefaultEnhancers = <M extends Middlewares<any>>(
|
|---|
| 17 | middlewareEnhancer: StoreEnhancer<{ dispatch: ExtractDispatchExtensions<M> }>,
|
|---|
| 18 | ): GetDefaultEnhancers<M> =>
|
|---|
| 19 | function getDefaultEnhancers(options) {
|
|---|
| 20 | const { autoBatch = true } = options ?? {}
|
|---|
| 21 |
|
|---|
| 22 | let enhancerArray = new Tuple<StoreEnhancer[]>(middlewareEnhancer)
|
|---|
| 23 | if (autoBatch) {
|
|---|
| 24 | enhancerArray.push(
|
|---|
| 25 | autoBatchEnhancer(
|
|---|
| 26 | typeof autoBatch === 'object' ? autoBatch : undefined,
|
|---|
| 27 | ),
|
|---|
| 28 | )
|
|---|
| 29 | }
|
|---|
| 30 | return enhancerArray as any
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.