Skip to content

Commit 86b5206

Browse files
authored
Disabling presence heartbeat by default (#146)
* Update package-lock.json after npm install - David * Fix eslint and prettier errors and typo - David * Setting the default presence heartbeat to false on subscribe - David * Update ESLint rules and fix others - David * Formatting and fixing broken tests - David * Format subscription_manager.test.js and fix tests - David * Format reconnection_manager.test.js and fix tests - David * Update versions and include the build - David * Fix linting errors and rules for Codacy checks - David * Fix broken tests for no longer specified pubnub.yml version - David * Update the date to now - David
1 parent 6d21244 commit 86b5206

20 files changed

+896
-401
lines changed

.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ rules:
2121
class-methods-use-this: 0
2222
no-await-in-loop: 0
2323
no-multi-assign: 0
24+
arrow-parens: [2, "as-needed"]
25+
operator-linebreak: ["error", "after"]
26+
no-mixed-operators: 0

.pubnub.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
---
22
changelog:
3+
-
4+
changes:
5+
-
6+
text: "Disables the presence heartbeat by default when a subscribe is called. Presence heartbeat can still be enabled explicitly."
7+
type: improvement
8+
date: 2019-05-09
9+
version: v4.24.0
310
-
411
changes:
512
-

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [v4.24.0](https://github.com/pubnub/javascript/tree/v4.24.0)
2+
May-09-2019
3+
4+
5+
[Full Changelog](https://github.com/pubnub/javascript/compare/v4.23.0...v4.24.0)
6+
7+
8+
9+
- ⭐ Disables the presence heartbeat by default when a subscribe is called. Presence heartbeat can still be enabled explicitly.
10+
11+
12+
113
## [v4.23.0](https://github.com/pubnub/javascript/tree/v4.23.0)
214
March-14-2019
315

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ please use the [master_3x](https://github.com/pubnub/javascript/tree/master_3x)
2222

2323

2424

25-
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.23.0.min.js
26-
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.23.0.js
25+
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.24.0.min.js
26+
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.24.0.js

dist/titanium/pubnub.js

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! 4.23.0 / Consumer */
1+
/*! 4.24.0 / Consumer */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -502,12 +502,14 @@ return /******/ (function(modules) { // webpackBootstrap
502502
}, {
503503
key: 'setAuthKey',
504504
value: function setAuthKey(val) {
505-
this.authKey = val;return this;
505+
this.authKey = val;
506+
return this;
506507
}
507508
}, {
508509
key: 'setCipherKey',
509510
value: function setCipherKey(val) {
510-
this.cipherKey = val;return this;
511+
this.cipherKey = val;
512+
return this;
511513
}
512514
}, {
513515
key: 'getUUID',
@@ -529,7 +531,8 @@ return /******/ (function(modules) { // webpackBootstrap
529531
}, {
530532
key: 'setFilterExpression',
531533
value: function setFilterExpression(val) {
532-
this.filterExpression = val;return this;
534+
this.filterExpression = val;
535+
return this;
533536
}
534537
}, {
535538
key: 'getPresenceTimeout',
@@ -556,7 +559,8 @@ return /******/ (function(modules) { // webpackBootstrap
556559
}, {
557560
key: 'setHeartbeatInterval',
558561
value: function setHeartbeatInterval(val) {
559-
this._heartbeatInterval = val;return this;
562+
this._heartbeatInterval = val;
563+
return this;
560564
}
561565
}, {
562566
key: 'getSubscribeTimeout',
@@ -566,7 +570,8 @@ return /******/ (function(modules) { // webpackBootstrap
566570
}, {
567571
key: 'setSubscribeTimeout',
568572
value: function setSubscribeTimeout(val) {
569-
this._subscribeRequestTimeout = val;return this;
573+
this._subscribeRequestTimeout = val;
574+
return this;
570575
}
571576
}, {
572577
key: 'getTransactionTimeout',
@@ -576,7 +581,8 @@ return /******/ (function(modules) { // webpackBootstrap
576581
}, {
577582
key: 'setTransactionTimeout',
578583
value: function setTransactionTimeout(val) {
579-
this._transactionalRequestTimeout = val;return this;
584+
this._transactionalRequestTimeout = val;
585+
return this;
580586
}
581587
}, {
582588
key: 'isSendBeaconEnabled',
@@ -586,12 +592,13 @@ return /******/ (function(modules) { // webpackBootstrap
586592
}, {
587593
key: 'setSendBeaconConfig',
588594
value: function setSendBeaconConfig(val) {
589-
this._useSendBeacon = val;return this;
595+
this._useSendBeacon = val;
596+
return this;
590597
}
591598
}, {
592599
key: 'getVersion',
593600
value: function getVersion() {
594-
return '4.23.0';
601+
return '4.24.0';
595602
}
596603
}, {
597604
key: '_decideUUID',
@@ -1441,7 +1448,9 @@ return /******/ (function(modules) { // webpackBootstrap
14411448
});
14421449

14431450
channelGroups.forEach(function (channelGroup) {
1444-
if (channelGroup in _this._channelGroups) _this._channelGroups[channelGroup].state = state;
1451+
if (channelGroup in _this._channelGroups) {
1452+
_this._channelGroups[channelGroup].state = state;
1453+
}
14451454
});
14461455

14471456
return this._setStateEndpoint({ state: state, channels: channels, channelGroups: channelGroups }, callback);
@@ -1501,11 +1510,13 @@ return /******/ (function(modules) { // webpackBootstrap
15011510
_args$withPresence = args.withPresence,
15021511
withPresence = _args$withPresence === undefined ? false : _args$withPresence,
15031512
_args$withHeartbeats = args.withHeartbeats,
1504-
withHeartbeats = _args$withHeartbeats === undefined ? true : _args$withHeartbeats;
1513+
withHeartbeats = _args$withHeartbeats === undefined ? false : _args$withHeartbeats;
15051514

15061515

15071516
if (!this._config.subscribeKey || this._config.subscribeKey === '') {
1508-
if (console && console.log) console.log('subscribe key missing; aborting subscribe');
1517+
if (console && console.log) {
1518+
console.log('subscribe key missing; aborting subscribe');
1519+
}
15091520
return;
15101521
}
15111522

@@ -1609,7 +1620,10 @@ return /******/ (function(modules) { // webpackBootstrap
16091620
}, {
16101621
key: 'unsubscribeAll',
16111622
value: function unsubscribeAll(isOffline) {
1612-
this.adaptUnsubscribeChange({ channels: this.getSubscribedChannels(), channelGroups: this.getSubscribedChannelGroups() }, isOffline);
1623+
this.adaptUnsubscribeChange({
1624+
channels: this.getSubscribedChannels(),
1625+
channelGroups: this.getSubscribedChannelGroups()
1626+
}, isOffline);
16131627
}
16141628
}, {
16151629
key: 'getHeartbeatChannels',
@@ -1681,12 +1695,16 @@ return /******/ (function(modules) { // webpackBootstrap
16811695

16821696
this.getSubscribedChannels().forEach(function (channel) {
16831697
var channelState = _this5._channels[channel].state;
1684-
if (Object.keys(channelState).length) presenceState[channel] = channelState;
1698+
if (Object.keys(channelState).length) {
1699+
presenceState[channel] = channelState;
1700+
}
16851701
});
16861702

16871703
this.getSubscribedChannelGroups().forEach(function (channelGroup) {
16881704
var channelGroupState = _this5._channelGroups[channelGroup].state;
1689-
if (Object.keys(channelGroupState).length) presenceState[channelGroup] = channelGroupState;
1705+
if (Object.keys(channelGroupState).length) {
1706+
presenceState[channelGroup] = channelGroupState;
1707+
}
16901708
});
16911709

16921710
var onHeartbeat = function onHeartbeat(status) {
@@ -1709,7 +1727,8 @@ return /******/ (function(modules) { // webpackBootstrap
17091727
this._heartbeatEndpoint({
17101728
channels: heartbeatChannels,
17111729
channelGroups: heartbeatChannelGroups,
1712-
state: presenceState }, onHeartbeat.bind(this));
1730+
state: presenceState
1731+
}, onHeartbeat.bind(this));
17131732
}
17141733
}, {
17151734
key: '_startSubscribeLoop',
@@ -1722,14 +1741,14 @@ return /******/ (function(modules) { // webpackBootstrap
17221741
return channels.push(channel);
17231742
});
17241743
Object.keys(this._presenceChannels).forEach(function (channel) {
1725-
return channels.push(channel + '-pnpres');
1744+
channels.push(channel + '-pnpres');
17261745
});
17271746

17281747
Object.keys(this._channelGroups).forEach(function (channelGroup) {
1729-
return channelGroups.push(channelGroup);
1748+
channelGroups.push(channelGroup);
17301749
});
17311750
Object.keys(this._presenceChannelGroups).forEach(function (channelGroup) {
1732-
return channelGroups.push(channelGroup + '-pnpres');
1751+
channelGroups.push(channelGroup + '-pnpres');
17331752
});
17341753

17351754
if (channels.length === 0 && channelGroups.length === 0) {

dist/titanium/pubnub.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web/pubnub.js

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! 4.23.0 / Consumer */
1+
/*! 4.24.0 / Consumer */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -524,12 +524,14 @@ return /******/ (function(modules) { // webpackBootstrap
524524
}, {
525525
key: 'setAuthKey',
526526
value: function setAuthKey(val) {
527-
this.authKey = val;return this;
527+
this.authKey = val;
528+
return this;
528529
}
529530
}, {
530531
key: 'setCipherKey',
531532
value: function setCipherKey(val) {
532-
this.cipherKey = val;return this;
533+
this.cipherKey = val;
534+
return this;
533535
}
534536
}, {
535537
key: 'getUUID',
@@ -551,7 +553,8 @@ return /******/ (function(modules) { // webpackBootstrap
551553
}, {
552554
key: 'setFilterExpression',
553555
value: function setFilterExpression(val) {
554-
this.filterExpression = val;return this;
556+
this.filterExpression = val;
557+
return this;
555558
}
556559
}, {
557560
key: 'getPresenceTimeout',
@@ -578,7 +581,8 @@ return /******/ (function(modules) { // webpackBootstrap
578581
}, {
579582
key: 'setHeartbeatInterval',
580583
value: function setHeartbeatInterval(val) {
581-
this._heartbeatInterval = val;return this;
584+
this._heartbeatInterval = val;
585+
return this;
582586
}
583587
}, {
584588
key: 'getSubscribeTimeout',
@@ -588,7 +592,8 @@ return /******/ (function(modules) { // webpackBootstrap
588592
}, {
589593
key: 'setSubscribeTimeout',
590594
value: function setSubscribeTimeout(val) {
591-
this._subscribeRequestTimeout = val;return this;
595+
this._subscribeRequestTimeout = val;
596+
return this;
592597
}
593598
}, {
594599
key: 'getTransactionTimeout',
@@ -598,7 +603,8 @@ return /******/ (function(modules) { // webpackBootstrap
598603
}, {
599604
key: 'setTransactionTimeout',
600605
value: function setTransactionTimeout(val) {
601-
this._transactionalRequestTimeout = val;return this;
606+
this._transactionalRequestTimeout = val;
607+
return this;
602608
}
603609
}, {
604610
key: 'isSendBeaconEnabled',
@@ -608,12 +614,13 @@ return /******/ (function(modules) { // webpackBootstrap
608614
}, {
609615
key: 'setSendBeaconConfig',
610616
value: function setSendBeaconConfig(val) {
611-
this._useSendBeacon = val;return this;
617+
this._useSendBeacon = val;
618+
return this;
612619
}
613620
}, {
614621
key: 'getVersion',
615622
value: function getVersion() {
616-
return '4.23.0';
623+
return '4.24.0';
617624
}
618625
}, {
619626
key: '_decideUUID',
@@ -1463,7 +1470,9 @@ return /******/ (function(modules) { // webpackBootstrap
14631470
});
14641471

14651472
channelGroups.forEach(function (channelGroup) {
1466-
if (channelGroup in _this._channelGroups) _this._channelGroups[channelGroup].state = state;
1473+
if (channelGroup in _this._channelGroups) {
1474+
_this._channelGroups[channelGroup].state = state;
1475+
}
14671476
});
14681477

14691478
return this._setStateEndpoint({ state: state, channels: channels, channelGroups: channelGroups }, callback);
@@ -1523,11 +1532,13 @@ return /******/ (function(modules) { // webpackBootstrap
15231532
_args$withPresence = args.withPresence,
15241533
withPresence = _args$withPresence === undefined ? false : _args$withPresence,
15251534
_args$withHeartbeats = args.withHeartbeats,
1526-
withHeartbeats = _args$withHeartbeats === undefined ? true : _args$withHeartbeats;
1535+
withHeartbeats = _args$withHeartbeats === undefined ? false : _args$withHeartbeats;
15271536

15281537

15291538
if (!this._config.subscribeKey || this._config.subscribeKey === '') {
1530-
if (console && console.log) console.log('subscribe key missing; aborting subscribe');
1539+
if (console && console.log) {
1540+
console.log('subscribe key missing; aborting subscribe');
1541+
}
15311542
return;
15321543
}
15331544

@@ -1631,7 +1642,10 @@ return /******/ (function(modules) { // webpackBootstrap
16311642
}, {
16321643
key: 'unsubscribeAll',
16331644
value: function unsubscribeAll(isOffline) {
1634-
this.adaptUnsubscribeChange({ channels: this.getSubscribedChannels(), channelGroups: this.getSubscribedChannelGroups() }, isOffline);
1645+
this.adaptUnsubscribeChange({
1646+
channels: this.getSubscribedChannels(),
1647+
channelGroups: this.getSubscribedChannelGroups()
1648+
}, isOffline);
16351649
}
16361650
}, {
16371651
key: 'getHeartbeatChannels',
@@ -1703,12 +1717,16 @@ return /******/ (function(modules) { // webpackBootstrap
17031717

17041718
this.getSubscribedChannels().forEach(function (channel) {
17051719
var channelState = _this5._channels[channel].state;
1706-
if (Object.keys(channelState).length) presenceState[channel] = channelState;
1720+
if (Object.keys(channelState).length) {
1721+
presenceState[channel] = channelState;
1722+
}
17071723
});
17081724

17091725
this.getSubscribedChannelGroups().forEach(function (channelGroup) {
17101726
var channelGroupState = _this5._channelGroups[channelGroup].state;
1711-
if (Object.keys(channelGroupState).length) presenceState[channelGroup] = channelGroupState;
1727+
if (Object.keys(channelGroupState).length) {
1728+
presenceState[channelGroup] = channelGroupState;
1729+
}
17121730
});
17131731

17141732
var onHeartbeat = function onHeartbeat(status) {
@@ -1731,7 +1749,8 @@ return /******/ (function(modules) { // webpackBootstrap
17311749
this._heartbeatEndpoint({
17321750
channels: heartbeatChannels,
17331751
channelGroups: heartbeatChannelGroups,
1734-
state: presenceState }, onHeartbeat.bind(this));
1752+
state: presenceState
1753+
}, onHeartbeat.bind(this));
17351754
}
17361755
}, {
17371756
key: '_startSubscribeLoop',
@@ -1744,14 +1763,14 @@ return /******/ (function(modules) { // webpackBootstrap
17441763
return channels.push(channel);
17451764
});
17461765
Object.keys(this._presenceChannels).forEach(function (channel) {
1747-
return channels.push(channel + '-pnpres');
1766+
channels.push(channel + '-pnpres');
17481767
});
17491768

17501769
Object.keys(this._channelGroups).forEach(function (channelGroup) {
1751-
return channelGroups.push(channelGroup);
1770+
channelGroups.push(channelGroup);
17521771
});
17531772
Object.keys(this._presenceChannelGroups).forEach(function (channelGroup) {
1754-
return channelGroups.push(channelGroup + '-pnpres');
1773+
channelGroups.push(channelGroup + '-pnpres');
17551774
});
17561775

17571776
if (channels.length === 0 && channelGroups.length === 0) {

dist/web/pubnub.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)