Open
Description
Problem
There is data that need to be polled if the result is still in progress
I want to do that polling in the injectEndpoints
configuration rather than in a hook. (maybe its not a good idea)
onCacheEntryAdded: async (arg, api) => {
// On query receieved, if its still in progress, start polling
try {
const data = await api.cacheDataLoaded;
if (
data.data.inferences.some(
(inference) => inference.status === "in-progress"
)
)
{
console.log("Found queries in progress, start the polling");
// await api.dispatch(
// apiSlice.endpoints.getInferences.initiate(arg, {
// subscriptionOptions: { pollingInterval: 3000 },
// })
// );
}
else {
console.log("No queries in progress, stop the polling if it was started");
// Stop the polling
}
} catch (error) {}
await api.cacheEntryRemoved;
console.log("stop the polling");
// Stop the polling
},
Here I do not manage to find the right set of api.X
or sliceApi.X
to start the poll or stop it if needed.