redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

response in providesTags is not currentCache

Open grtan opened this issue 2 years ago • 1 comments

response in providesTags is not currentCache when use with merge, response in here is the result of each request, not results of all requests

I try store.getState(), but it throw an error

    providesTags(response, error, {domainId}) {
          /**
           * response in here is the result of each request, not results of all requests
           * so we need get the complete cache
           */
           ({data: response} = api.endpoints.getMigrations.select({
             domainId,
           })(store.getState()));

          return response
            ? [
                ...migrationsAdapter
                  .getSelectors()
                  .selectIds(response)
                  .map((id) => ({
                    type: TYPE.MIGRATION,
                    id: JSON.stringify([domainId, id]),
                  })),
                {
                  type: TYPE.MIGRATION,
                  id: JSON.stringify([domainId, 'LIST']),
                },
              ]
            : [
                {
                  type: TYPE.MIGRATION,
                  domainId: JSON.stringify([domainId, 'LIST']),
                },
              ];
        },
image

How to get the complete currentCache in providesTags?

grtan avatar Jul 07 '23 09:07 grtan