You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
We could introduce a cacheEntryContext next to the existing requestContext (renamed from just context and add two new lifecycle callbacks: cacheEntryAdded and cacheEntryCleared.
Those two lifecycles would allow supporting stuff like graphql subscriptions or websocket streams.
getPosts: build.query({query: (arg)=>({url: `posts`}),// fetches data that will then be updated by a subscriptioncacheEntryAdded(arg,{ dispatch, cacheEntryContext }){cacheEntryContext.stopListening=ws.listen(()=>{// ... dispatch(api.util.updateQueryResult('cacheEntryAdded',arg,(draft)=>{draft.foo= ...
}))})},cacheEntryCleared({ id },{ dispatch, cacheEntryContext }){cacheEntryContext.stopListening()},}),
OR we go useEffect here and have cacheEntryAdded just return a cleanup callback. Then we could skip all the cacheEntryContext nonsense and omit cacheEntryCleared
getPosts: build.query({query: (arg)=>({url: `posts`}),// fetches data that will then be updated by a subscriptioncacheEntryAdded(arg,{ dispatch }){conststopListening=ws.listen(()=>{// ... dispatch(api.util.updateQueryResult('cacheEntryAdded',arg,(draft)=>{draft.foo= ...
}))})return()=>{stopListening()}}}),
The text was updated successfully, but these errors were encountered:
Lenz just put up a commit with hypothetical designs for three different variations on this concept: "context"-based, "callback"-based, and "promise"-based:
We could introduce a
cacheEntryContext
next to the existingrequestContext
(renamed from justcontext
and add two new lifecycle callbacks:cacheEntryAdded
andcacheEntryCleared
.Those two lifecycles would allow supporting stuff like graphql subscriptions or websocket streams.
OR we go
useEffect
here and havecacheEntryAdded
just return a cleanup callback. Then we could skip all thecacheEntryContext
nonsense and omitcacheEntryCleared
The text was updated successfully, but these errors were encountered: