Support Topics Documentation Slack YouTube Blog

Real time connection listeners management

Hi
im having an issue where i have double the listeners for the same purpose
my question is: how can i manage the connection listener?

Are you getting real time events more than once? If not, how did you determine that you have double listeners?

The way to solve it is only by debugging your code.

Regards,
Mark

yes I have checked the connection chanel listeners and I see double listener with the same selector

So how can I check in my code if the listener with the selector exists?

Hello @mohammad_altoiher

we don’t have a specific API for that, however, you can find all the subscriptions in the private variable subscriptions of the messaging channel, the same with RT-Data listeners.

But keep in mind that this is not either public and documented API and it might be changed in future releases. So I can recommend you to handle it on your own, for instance, you can have a hash-map or array of your subscriptions.

Or, I assume the best way is to keep your logic as clear as possible, once a component is appeared you add a particular subscription and when it goes away stop the subscription

Regards, Vlad

i wish you guys add something to make it more solid to handle the listeners.
with mobile apps its hard to predict if something goes wrong with the connection or the app state.
so its better to check if a specific listener still exists instead of relaying on a possibility that its there.