Skip to content

[Solved] Combine the result of two different RTK queries into one selector or update one cache when another request is done #3169

Answered by ovistoica
ovistoica asked this question in Q&A
Discussion options

You must be logged in to vote

Update:

The listener worked but I was using wrong update method with entityAdapter. Correct usage:

listenerApi.dispatch(
      userManagementSlice.util.updateQueryData(
        'getAdminUsers',
        undefined,
        (draft) => {
          adminUsersAdapter.upsertOne(draft, payload);
        }
      )
    );

Also for my case, this was sometimes not working because of race condition between the two calls so I need to add an initiate or prefetch for the admin/users call so that the cache entry is always in place

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ovistoica
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant