@@ -26,7 +26,7 @@ import { createReducer } from './createReducer'
26
26
import type { ActionReducerMapBuilder , TypedActionCreator } from './mapBuilders'
27
27
import { executeReducerBuilderCallback } from './mapBuilders'
28
28
import type { Id , TypeGuard } from './tsHelpers'
29
- import { emplace } from './utils'
29
+ import { getOrInsertComputed } from './utils'
30
30
31
31
const asyncThunkSymbol = /* @__PURE__ */ Symbol . for (
32
32
'rtk-slice-createasyncthunk' ,
@@ -769,25 +769,25 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
769
769
function getSelectors (
770
770
selectState : ( rootState : any ) => State = selectSelf ,
771
771
) {
772
- const selectorCache = emplace ( injectedSelectorCache , injected , {
773
- insert : ( ) => new WeakMap ( ) ,
774
- } )
775
-
776
- return emplace ( selectorCache , selectState , {
777
- insert : ( ) => {
778
- const map : Record < string , Selector < any , any > > = { }
779
- for ( const [ name , selector ] of Object . entries (
780
- options . selectors ?? { } ,
781
- ) ) {
782
- map [ name ] = wrapSelector (
783
- selector ,
784
- selectState ,
785
- getInitialState ,
786
- injected ,
787
- )
788
- }
789
- return map
790
- } ,
772
+ const selectorCache = getOrInsertComputed (
773
+ injectedSelectorCache ,
774
+ injected ,
775
+ ( ) => new WeakMap ( ) ,
776
+ )
777
+
778
+ return getOrInsertComputed ( selectorCache , selectState , ( ) => {
779
+ const map : Record < string , Selector < any , any > > = { }
780
+ for ( const [ name , selector ] of Object . entries (
781
+ options . selectors ?? { } ,
782
+ ) ) {
783
+ map [ name ] = wrapSelector (
784
+ selector ,
785
+ selectState ,
786
+ getInitialState ,
787
+ injected ,
788
+ )
789
+ }
790
+ return map
791
791
} ) as any
792
792
}
793
793
return {
0 commit comments