-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new listener interface #359
Conversation
…Subscription`, `SubscriptionSet` entities definitions
…o support new listener interface
|
…istenr tests * fix: unique channel and groups for subscription, no telemetry for event engine, avoid duplicate listener registration
…criptionSet operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good in general, but I have some questions.
src/entities/Subscription.ts
Outdated
subscribe() { | ||
this.pubnub.subscribe({ | ||
channels: this.channelNames, | ||
channelGroups: this.groupNames, | ||
...(this.options?.cursor?.timetoken && { timetoken: this.options.cursor.timetoken }), | ||
}); | ||
} | ||
unsubscribe() { | ||
this.pubnub.unsubscribe({ channels: this.channelNames, channelGroups: this.groupNames }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand we currently use simplified version without entities usage tracking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listeners will pass entity names to subscribe/unsubscribe call as it is.
to make this logic at one central place it's handled (assorting overlapping channels/groups)in this file. So that presence apis will also called /optimised accordingly.
- added utility methods to assort unique/overlapping channel/groups. to make decision whether to remove/add incoming channel/group names into subscription/presence event engine.
…criptions when channels/groups set is provided
…with new listener/entity interface
* refactor subscription/subscriptionSet class definition through common abstract class.
@parfeon Ready for review.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one question about abstract class implementation.
protected abstract channelNames: string[]; | ||
protected abstract groupNames: string[]; | ||
protected abstract listener: Listener; | ||
protected abstract eventEmitter: EventEmitter; | ||
protected abstract pubnub: PubNub; | ||
protected abstract options?: SubscriptionOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this and there will be no need to declare them in subclasses:
protected abstract channelNames: string[]; | |
protected abstract groupNames: string[]; | |
protected abstract listener: Listener; | |
protected abstract eventEmitter: EventEmitter; | |
protected abstract pubnub: PubNub; | |
protected abstract options?: SubscriptionOptions; | |
protected channelNames: string[] = []; | |
protected groupNames: string[] = []; | |
protected listener: Listener; | |
protected eventEmitter: EventEmitter; | |
protected pubnub: PubNub; | |
protected options?: SubscriptionOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is,
if we declare it like:
protected listener: Listener;
it forces us to make type Listener | undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a suggestion to move properties to the abstract class, so there will be no need to declare them again in all subclasses. If it is ok like we have it now, then np ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@pubnub-release-bot release as v7.6.0 |
🚀 Release successfully completed 🚀 |
feat(api): adding first-class citizens to access subscription. Enabling subscription specific event listeners.
Adding channel, channelGroup, channelMetadata and userMetadata entities to be first-class citizens to access APIs related to them. Currently, access is provided only for subscription API.