Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*__note:__ the # at the end of lines are the pull request numbers on GitHub*

# 2.1.4

* Fix `onDone` callbacks being lost when subscribing in a `disconnected` state #121

# 2.1.3

* https://github.com/kuzzleio/sdk-javascript/releases/tag/2.1.3
Expand Down
2 changes: 1 addition & 1 deletion dist/kuzzle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kuzzle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "2.1.3",
"version": "2.1.4",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <support@kuzzle.io>",
"repository": {
Expand Down
12 changes: 11 additions & 1 deletion src/kuzzleRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function KuzzleRoom(kuzzleDataCollection, options) {
value: null,
writable: true
},
onDoneCB: {
value: null,
writable: true
},
queue: {
value: [],
writable: true
Expand Down Expand Up @@ -166,13 +170,17 @@ KuzzleRoom.prototype.renew = function (filters, notificationCB, cb) {
filters = null;
}

if (!cb) {
cb = self.onDoneCB;
}

self.kuzzle.callbackRequired('KuzzleRoom.renew', notificationCB);

/*
Skip subscription renewal if another one was performed a moment before
*/
if (self.lastRenewal && (now - self.lastRenewal) <= self.renewalDelay) {
return;
return cb && cb(new Error('Subscription already renewed less than ' + self.renewalDelay + 'ms ago'));
}

if (filters) {
Expand All @@ -185,6 +193,7 @@ KuzzleRoom.prototype.renew = function (filters, notificationCB, cb) {
*/
if (self.kuzzle.state !== 'connected') {
self.callback = notificationCB;
self.onDoneCB = cb;
self.kuzzle.subscriptions.pending[self.id] = self;
return;
}
Expand All @@ -198,6 +207,7 @@ KuzzleRoom.prototype.renew = function (filters, notificationCB, cb) {
self.roomId = null;
self.subscribing = true;
self.callback = notificationCB;
self.onDoneCB = cb;
self.kuzzle.subscriptions.pending[self.id] = self;

subscribeQuery.body = self.filters;
Expand Down