|
1 | 1 | import { Dictionary } from '@reduxjs/toolkit'
|
2 | 2 | import {
|
3 |
| - defaultSerializeQueryArgs, |
4 |
| - SerializeQueryArgs, |
| 3 | + defaultSerializeQueryArgs, |
| 4 | + SerializeQueryArgs, |
5 | 5 | } from './query/defaultSerializeQueryArgs'
|
6 | 6 |
|
7 | 7 | export function buildSerializeQueryArgs(
|
8 |
| - globalSerializer: SerializeQueryArgs<any> = defaultSerializeQueryArgs |
| 8 | + globalSerializer: SerializeQueryArgs<any> = defaultSerializeQueryArgs |
9 | 9 | ) {
|
10 |
| - const endpointSpecificSerializers: Dictionary<SerializeQueryArgs<any>> = {} |
11 |
| - |
12 |
| - const serializeQueryArgs: SerializeQueryArgs<any> = (params) => { |
13 |
| - const endpointSpecificSerializer = |
14 |
| - endpointSpecificSerializers[params.endpointName] |
15 |
| - |
16 |
| - if (endpointSpecificSerializer) { |
17 |
| - return endpointSpecificSerializer(params) |
18 |
| - } |
19 |
| - |
20 |
| - return globalSerializer(params) |
21 |
| - } |
22 |
| - |
23 |
| - const registerArgsSerializerForEndpoint = ( |
24 |
| - endpointName: string, |
25 |
| - serializer: SerializeQueryArgs<any> |
26 |
| - ) => { |
27 |
| - endpointSpecificSerializers[endpointName] = serializer |
28 |
| - } |
29 |
| - |
30 |
| - return { |
31 |
| - serializeQueryArgs, |
32 |
| - registerArgsSerializerForEndpoint, |
33 |
| - } |
| 10 | + const endpointSpecificSerializers: Dictionary<SerializeQueryArgs<any>> = {} |
| 11 | + |
| 12 | + const serializeQueryArgs: SerializeQueryArgs<any> = (params) => { |
| 13 | + const endpointSpecificSerializer = |
| 14 | + endpointSpecificSerializers[params.endpointName] |
| 15 | + |
| 16 | + if (endpointSpecificSerializer) { |
| 17 | + return endpointSpecificSerializer(params) |
| 18 | + } |
| 19 | + |
| 20 | + return globalSerializer(params) |
| 21 | + } |
| 22 | + |
| 23 | + const registerArgsSerializerForEndpoint = ( |
| 24 | + endpointName: string, |
| 25 | + serializer: SerializeQueryArgs<any> |
| 26 | + ) => { |
| 27 | + endpointSpecificSerializers[endpointName] = serializer |
| 28 | + } |
| 29 | + |
| 30 | + return { |
| 31 | + serializeQueryArgs, |
| 32 | + registerArgsSerializerForEndpoint, |
| 33 | + } |
34 | 34 | }
|
0 commit comments