redux-toolkit
redux-toolkit copied to clipboard
response in providesTags is not currentCache
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']),
},
];
},
How to get the complete currentCache in providesTags?