-
Hello everyone! Im using anycable-client library in React, and i have this case: useEffect(() => {
const channel = consumer.subscribeTo('CardChannel', { id });
channel.on('message', handleMessage);
return () => {
channel.disconnect();
};
}, [consumer, id]); We have 2 active tabs which uses the same consumer, and creates up to 30 channels (one per card, 60 max with both tabs). Another question: Thank you all in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Nope. We do not make any assumptions regarding when to remove event listeners; you might want to reconnect the same channel instance later again and keep your listeners. Thus, you need to take care of removing listeners yourself. In your case: let unbindMessage = channel.on('message', handleMessage);
return () => {
unbindMessage();
channel.disconnect();
};
Yes. See this note from the Readme:
|
Beta Was this translation helpful? Give feedback.
Nope. We do not make any assumptions regarding when to remove event listeners; you might want to reconnect the same channel instance later again and keep your listeners. Thus, you need to take care of removing listeners yourself. In your case:
Yes. See this note from the Readme: