I tried to call an unsubscribe function:
unsubscribeFromThingIds(arg.tids);
after the await cacheEntryRemoved;
line in this example.
The function is defined like this:
export const unsubscribeFromThingIds = (tids: string[]) => {
followedThingIds = followedThingIds.filter(
id => !tids.includes(id)
);
const argument = { tids: followedThingIds } as ITimersChannelInitParams;
myIo!.emit("configure timers channel", argument);
};
(where myIo
is the Socket.IO client)
This is not working currently for me. I am currently debugging this issue.
I also tried to use an useEffect
hook with a returned cleanup function for running it when the component unmounts, something like this:
useEffect(() => {
return () => {
unsubscribeFromThingIds(getTimersQueryParams.tids);
};
}, [getTimersQueryParams]);
I want to ask for this information because I am not sure which one of the two ideas should I work on more, or if there is another thing I can do that is better.