pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

Accessing active listeners #350

Open RaedKhalafDAZN opened 11 months ago

RaedKhalafDAZN commented 11 months ago

Currently, we are using Pubnub.addListener get get access to messages streams,

but, due to multiple channels subscriptions in different parts of the application, we would like to get access to the current active listeners,

and maybe we can add UUID identifiers for each listeners.

parfeon commented 11 months ago

What do you mean by “access to the current active listeners”? What exactly expected from access to the list of functions?

RaedKhalafDAZN commented 11 months ago

@parfeon I mean, we have in listernes_manager.js all sort of functions to CUD listeners, but we are missing Read of the current listeners.

in listeners_manager.js

  removeAllListeners() {
    this._listeners = [];
  }

  // Added
  getAllListeners() {
    return this._listeners;
  }

In Reactive JS application, we need to react to certain types of events in different parts of the application, when we call "AddListener" to pubnub, we need to make sure its not already added before.

because it will create duplicate messages to the platform.

parfeon commented 11 months ago

@RaedKhalafDAZN thank you for clarification.

This listener stores listeners created at some point and then re-use them when you want to register? If they are the same function objects (during repetitive registration and removal), then from our side we can try to validate whether the listener already added or not.

RaedKhalafDAZN commented 11 months ago

Hi @parfeon, that would be great! can we have a timeline to do that ? I can contribute to support this.

RaedKhalafDAZN commented 10 months ago

@parfeon any updates ?

parfeon commented 10 months ago

@RaedKhalafDAZN i apologize for long response. We will make enhancement in upcoming release (end of this week or start of the next)