Skip to content

Commit 6d0db5e

Browse files
committed
add entity methods creator to ReducerType enum
1 parent 0102cc3 commit 6d0db5e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

packages/toolkit/src/createSlice.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ import type {
2020
ReducerWithInitialState,
2121
} from './createReducer'
2222
import { createReducer, makeGetInitialState } from './createReducer'
23-
import type {
24-
EntityMethodsCreator,
25-
entityMethodsCreatorType,
26-
} from './entities/slice_creator'
23+
import type { EntityMethodsCreator } from './entities/slice_creator'
2724
import type { ActionReducerMapBuilder, TypedActionCreator } from './mapBuilders'
2825
import { executeReducerBuilderCallback } from './mapBuilders'
2926
import type {
@@ -40,6 +37,7 @@ export enum ReducerType {
4037
reducer = 'reducer',
4138
reducerWithPrepare = 'reducerWithPrepare',
4239
asyncThunk = 'asyncThunk',
40+
entityMethods = 'entityMethods',
4341
}
4442

4543
export type RegisteredReducerType = keyof SliceReducerCreators<
@@ -150,7 +148,7 @@ export interface SliceReducerCreators<
150148
AsyncThunkCreator<State>,
151149
AsyncThunkCreatorExposes<State, CaseReducers>
152150
>
153-
[entityMethodsCreatorType]: ReducerCreatorEntry<EntityMethodsCreator<State>>
151+
[ReducerType.entityMethods]: ReducerCreatorEntry<EntityMethodsCreator<State>>
154152
}
155153

156154
export type ReducerCreators<

packages/toolkit/src/entities/slice_creator.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
PayloadAction,
44
ReducerCreator,
55
} from '@reduxjs/toolkit'
6-
import { reducerCreator } from '../createSlice'
6+
import { reducerCreator, ReducerType } from '../createSlice'
77
import type { WithRequiredProp } from '../tsHelpers'
88
import type {
99
EntityAdapter,
@@ -14,8 +14,6 @@ import type {
1414
} from './models'
1515
import { capitalize } from './utils'
1616

17-
export const entityMethodsCreatorType = '@@rtk/entityMethodsCreator'
18-
1917
export interface EntityMethodsCreatorConfig<
2018
T,
2119
Id extends EntityId,
@@ -124,9 +122,7 @@ export function createEntityMethods<
124122
return reducers as any
125123
}
126124

127-
export const entityMethodsCreator: ReducerCreator<
128-
typeof entityMethodsCreatorType
129-
> = {
130-
type: entityMethodsCreatorType,
125+
export const entityMethodsCreator: ReducerCreator<ReducerType.entityMethods> = {
126+
type: ReducerType.entityMethods,
131127
create: createEntityMethods,
132128
}

0 commit comments

Comments
 (0)