Skip to content

Commit

Permalink
try again in order
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Apr 22, 2024
1 parent e985deb commit f6c2717
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/data/src/redux-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,12 @@ function mapSelectorWithResolver(
queuesByRegistry.set( registry, queue );
}

function startResolution() {
async function fulfillResolution() {
resolversCache.clear( selectorName, args );
store.dispatch(
metadataActions.startResolution( selectorName, args )
);
}

async function fulfillResolution() {
try {
const action = resolver.fulfill( ...args );
if ( action ) {
Expand All @@ -648,22 +646,18 @@ function mapSelectorWithResolver(
}
}

queue.push( [ startResolution, fulfillResolution ] );
queue.push( fulfillResolution );

setTimeout( () => {
if ( queue.length ) {
// Many resolvers can be called at once. The point of this is to
// at least batch `startResolution` actions all together.
registry.batch( () => {
for ( const [ start ] of queue ) {
start();
for ( const fulfill of queue ) {
fulfill();
}
} );

for ( const [ , fulfill ] of queue ) {
fulfill();
}

queue.length = 0;
}
}, 0 );
Expand Down

0 comments on commit f6c2717

Please sign in to comment.