Skip to content

Commit 1e32286

Browse files
authored
Merge pull request #98 from kuzzleio/publishMessageCB
added callback to kuzzledatacollection.publishmessage
2 parents f0f45b8 + 028213a commit 1e32286

File tree

5 files changed

+14
-42
lines changed

5 files changed

+14
-42
lines changed

dist/kuzzle.js

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,12 @@
22
// shim for using process in browser
33

44
var process = module.exports = {};
5-
6-
// cached from whatever global is present so that test runners that stub it
7-
// don't break things. But we need to wrap it in a try catch in case it is
8-
// wrapped in strict mode code which doesn't define any globals. It's inside a
9-
// function because try/catches deoptimize in certain engines.
10-
11-
var cachedSetTimeout;
12-
var cachedClearTimeout;
13-
14-
(function () {
15-
try {
16-
cachedSetTimeout = setTimeout;
17-
} catch (e) {
18-
cachedSetTimeout = function () {
19-
throw new Error('setTimeout is not defined');
20-
}
21-
}
22-
try {
23-
cachedClearTimeout = clearTimeout;
24-
} catch (e) {
25-
cachedClearTimeout = function () {
26-
throw new Error('clearTimeout is not defined');
27-
}
28-
}
29-
} ())
305
var queue = [];
316
var draining = false;
327
var currentQueue;
338
var queueIndex = -1;
349

3510
function cleanUpNextTick() {
36-
if (!draining || !currentQueue) {
37-
return;
38-
}
3911
draining = false;
4012
if (currentQueue.length) {
4113
queue = currentQueue.concat(queue);
@@ -51,7 +23,7 @@ function drainQueue() {
5123
if (draining) {
5224
return;
5325
}
54-
var timeout = cachedSetTimeout(cleanUpNextTick);
26+
var timeout = setTimeout(cleanUpNextTick);
5527
draining = true;
5628

5729
var len = queue.length;
@@ -68,7 +40,7 @@ function drainQueue() {
6840
}
6941
currentQueue = null;
7042
draining = false;
71-
cachedClearTimeout(timeout);
43+
clearTimeout(timeout);
7244
}
7345

7446
process.nextTick = function (fun) {
@@ -80,7 +52,7 @@ process.nextTick = function (fun) {
8052
}
8153
queue.push(new Item(fun, args));
8254
if (queue.length === 1 && !draining) {
83-
cachedSetTimeout(drainQueue, 0);
55+
setTimeout(drainQueue, 0);
8456
}
8557
};
8658

@@ -120,7 +92,6 @@ process.chdir = function (dir) {
12092
process.umask = function() { return 0; };
12193

12294
},{}],2:[function(require,module,exports){
123-
(function (Buffer){
12495
// uuid.js
12596
//
12697
// Copyright (c) 2010-2012 Robert Kieffer
@@ -394,7 +365,6 @@ process.umask = function() { return 0; };
394365
}
395366
})('undefined' !== typeof window ? window : null);
396367

397-
}).call(this,require("buffer").Buffer)
398368
},{}],3:[function(require,module,exports){
399369
(function (process){
400370
var
@@ -2247,9 +2217,10 @@ KuzzleDataCollection.prototype.getMapping = function (options, cb) {
22472217
*
22482218
* @param {object} document - either a KuzzleDocument instance or a JSON object
22492219
* @param {object} [options] - optional arguments
2220+
* @param {responseCallback} [cb] - Returns a raw Kuzzle response
22502221
* @returns {*} this
22512222
*/
2252-
KuzzleDataCollection.prototype.publishMessage = function (document, options) {
2223+
KuzzleDataCollection.prototype.publishMessage = function (document, options, cb) {
22532224
var data = {};
22542225

22552226
if (document instanceof KuzzleDocument) {
@@ -2259,7 +2230,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
22592230
}
22602231

22612232
data = this.kuzzle.addHeaders(data, this.headers);
2262-
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options);
2233+
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options, cb);
22632234

22642235
return this;
22652236
};

dist/kuzzle.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/kuzzle.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "1.9.2",
3+
"version": "1.9.3",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <[email protected]>",
66
"repository": {

src/kuzzleDataCollection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,10 @@ KuzzleDataCollection.prototype.getMapping = function (options, cb) {
402402
*
403403
* @param {object} document - either a KuzzleDocument instance or a JSON object
404404
* @param {object} [options] - optional arguments
405+
* @param {responseCallback} [cb] - Returns a raw Kuzzle response
405406
* @returns {*} this
406407
*/
407-
KuzzleDataCollection.prototype.publishMessage = function (document, options) {
408+
KuzzleDataCollection.prototype.publishMessage = function (document, options, cb) {
408409
var data = {};
409410

410411
if (document instanceof KuzzleDocument) {
@@ -414,7 +415,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
414415
}
415416

416417
data = this.kuzzle.addHeaders(data, this.headers);
417-
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options);
418+
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options, cb);
418419

419420
return this;
420421
};

0 commit comments

Comments
 (0)