Skip to content

Commit

Permalink
fix: subscribe() signature to accept timetoken in subscribe() method
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Jun 17, 2024
1 parent 07a19e8 commit 3ca11b3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -8963,9 +8963,9 @@
}

class SubscribeCapable {
subscribe() {
var _a, _b;
this.pubnub.subscribe(Object.assign({ channels: this.channelNames, channelGroups: this.groupNames }, (((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.cursor) === null || _b === void 0 ? void 0 : _b.timetoken) && { timetoken: this.options.cursor.timetoken })));
subscribe(subscribeParameters) {
let timetoken = subscribeParameters === null || subscribeParameters === void 0 ? void 0 : subscribeParameters.timetoken;
this.pubnub.subscribe(Object.assign({ channels: this.channelNames, channelGroups: this.groupNames }, ((timetoken !== null && timetoken !== '') && { timetoken: timetoken })));
}
unsubscribe() {
this.pubnub.unsubscribe({
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/entities/SubscribeCapable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscribeCapable = void 0;
class SubscribeCapable {
subscribe() {
var _a, _b;
this.pubnub.subscribe(Object.assign({ channels: this.channelNames, channelGroups: this.groupNames }, (((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.cursor) === null || _b === void 0 ? void 0 : _b.timetoken) && { timetoken: this.options.cursor.timetoken })));
subscribe(subscribeParameters) {
let timetoken = subscribeParameters === null || subscribeParameters === void 0 ? void 0 : subscribeParameters.timetoken;
this.pubnub.subscribe(Object.assign({ channels: this.channelNames, channelGroups: this.groupNames }, ((timetoken !== null && timetoken !== '') && { timetoken: timetoken })));
}
unsubscribe() {
this.pubnub.unsubscribe({
Expand Down
4 changes: 3 additions & 1 deletion lib/types/entities/SubscribeCapable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export declare abstract class SubscribeCapable {
protected abstract eventEmitter: EventEmitter;
protected abstract pubnub: PubNub<unknown, unknown>;
protected abstract options?: SubscriptionOptions;
subscribe(): void;
subscribe(subscribeParameters?: {
timetoken?: string;
}): void;
unsubscribe(): void;
set onMessage(onMessageListener: (messageEvent: Subscription.Message) => void);
set onPresence(onPresenceListener: (presenceEvent: Subscription.Presence) => void);
Expand Down
4 changes: 0 additions & 4 deletions lib/types/entities/commonTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export type SubscriptionOptions = {
cursor?: {
timetoken?: string;
region?: number;
};
receivePresenceEvents?: boolean;
};
5 changes: 3 additions & 2 deletions src/entities/SubscribeCapable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export abstract class SubscribeCapable {
protected abstract pubnub: PubNub<unknown, unknown>;
protected abstract options?: SubscriptionOptions;

subscribe() {
subscribe(subscribeParameters?:{timetoken?: string}) {

Check failure on line 15 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (18.18.0, ci:node)

Replace `{timetoken?:·string` with `·{·timetoken?:·string·`

Check failure on line 15 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (20, ci:node)

Replace `{timetoken?:·string` with `·{·timetoken?:·string·`
let timetoken = subscribeParameters?.timetoken;

Check failure on line 16 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (18.18.0, ci:node)

'timetoken' is never reassigned. Use 'const' instead

Check failure on line 16 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (20, ci:node)

'timetoken' is never reassigned. Use 'const' instead
this.pubnub.subscribe({
channels: this.channelNames,
channelGroups: this.groupNames,
...(this.options?.cursor?.timetoken && { timetoken: this.options.cursor.timetoken }),
...((timetoken !== null && timetoken !== '') && { timetoken: timetoken }),

Check failure on line 20 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (18.18.0, ci:node)

Replace `(timetoken·!==·null·&&·timetoken·!==·'')` with `timetoken·!==·null·&&·timetoken·!==·''`

Check failure on line 20 in src/entities/SubscribeCapable.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (20, ci:node)

Replace `(timetoken·!==·null·&&·timetoken·!==·'')` with `timetoken·!==·null·&&·timetoken·!==·''`
});
}
unsubscribe() {
Expand Down
3 changes: 1 addition & 2 deletions src/entities/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type SubscriptionOptions = {
cursor?: { timetoken?: string; region?: number };
export type SubscriptionOptions = {

Check failure on line 1 in src/entities/commonTypes.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (18.18.0, ci:node)

Delete `··`

Check failure on line 1 in src/entities/commonTypes.ts

View workflow job for this annotation

GitHub Actions / Integration and Unit tests (20, ci:node)

Delete `··`
receivePresenceEvents?: boolean;
};

0 comments on commit 3ca11b3

Please sign in to comment.