rtk-incubator / rtk-query

Data fetching and caching addon for Redux Toolkit
https://redux-toolkit.js.org/rtk-query/overview
MIT License
626 stars 31 forks source link

Add `utils.invalidateEntities` #190

Closed msutkowski closed 3 years ago

msutkowski commented 3 years ago

This needs some help regarding the types because they're currently a :potato:.

Allows a user to invalidate entities at any point without firing off a mutation or calling refetch on a specific endpoint. Supports ['Entity', { type: 'OtherEntity' }, { type: 'EntityWithId', id: 1 }]

I also thought it'd be cool if we could do a const invalidate = useInvalidateEntities();, but I'm not sure of how to get the EntityTypes there without some magic.

codesandbox-ci[bot] commented 3 years ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 876510f622297d85acf908fec5f100323039644f:

Sandbox Source
React Configuration
React Typescript Configuration
rtk-query-demo Configuration
svelte-app-rtk-simplequery-demo Configuration
github-actions[bot] commented 3 years ago

size-limit report 📦

Path Size
ESM full 9.8 KB (+0.4% 🔺)
ESM full (React) 10.88 KB (+0.34% 🔺)
createApi + setupListeners 8.93 KB (+0.47% 🔺)
createApi (React) + setupListeners 9.89 KB (+0.43% 🔺)
fetchBaseQuery 661 B (0%)
retry 271 B (0%)
ApiProvider 400 B (0%)
CJS minfied 15.19 KB (+0.39% 🔺)
CJS React minfied 16.44 KB (+0.28% 🔺)