Skip to content

Commit ae270a1

Browse files
authored
Data: Improve hasResolvingSelectors redux metadata selector (#50865)
* Remove unnecessary array cloning * Document internal property usage * Use Array.from() instead of spread * Correct docs
1 parent b9df4b1 commit ae270a1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/data/src/redux-store/metadata/selectors.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,15 @@ export function getCachedResolvers( state ) {
140140
* @return {boolean} True if one or more selectors are resolving, false otherwise.
141141
*/
142142
export function hasResolvingSelectors( state ) {
143-
return [ ...Object.values( state ) ].some( ( selectorState ) =>
144-
[ ...selectorState._map.values() ].some(
143+
return Object.values( state ).some( ( selectorState ) =>
144+
/**
145+
* This uses the internal `_map` property of `EquivalentKeyMap` for
146+
* optimization purposes, since the `EquivalentKeyMap` implementation
147+
* does not support a `.values()` implementation.
148+
*
149+
* @see https://github.com/aduth/equivalent-key-map
150+
*/
151+
Array.from( selectorState._map.values() ).some(
145152
( resolution ) => resolution[ 1 ]?.status === 'resolving'
146153
)
147154
);

0 commit comments

Comments
 (0)