Skip to content

Commit 375d048

Browse files
committed
DRY probeType
1 parent 0d4bbd7 commit 375d048

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/toolkit/src/dynamicMiddleware/tests/index.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { isAction } from '../../createAction'
66
import { createAction } from '../../createAction'
77
import { isAllOf } from '../../matchers'
88

9-
export interface ProbeMiddleware
10-
extends BaseActionCreator<number, 'probeableMW/probe'> {
11-
<Id extends number>(id: Id): PayloadAction<Id, 'probeableMW/probe'>
9+
const probeType = 'probeableMW/probe'
10+
11+
type ProbeType = typeof probeType
12+
13+
export interface ProbeMiddleware extends BaseActionCreator<number, ProbeType> {
14+
<Id extends number>(id: Id): PayloadAction<Id, ProbeType>
1215
}
1316

14-
export const probeMiddleware = createAction<number>(
15-
'probeableMW/probe'
16-
) as ProbeMiddleware
17+
export const probeMiddleware = createAction(probeType) as ProbeMiddleware
1718

1819
const matchId =
1920
<Id extends number>(id: Id) =>
@@ -23,7 +24,7 @@ const matchId =
2324
export const makeProbeableMiddleware = <Id extends number>(
2425
id: Id
2526
): Middleware<{
26-
(action: PayloadAction<Id, 'probeableMW/probe'>): Id
27+
(action: PayloadAction<Id, ProbeType>): Id
2728
}> => {
2829
const isMiddlewareAction = isAllOf(isAction, probeMiddleware, matchId(id))
2930
return (api) => (next) => (action) => {

0 commit comments

Comments
 (0)