Comparing version 0.4.2 to 0.4.3
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -71,3 +73,3 @@ | ||
_this.onTransportClose = function (reason) { | ||
_this.sequence = 1; | ||
_this.operationUid = 1; | ||
_this.id = null; | ||
@@ -79,3 +81,4 @@ _this.connected = false; | ||
_this.onTransportReadable = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var message, doc; | ||
var message, _message$document$spl, _message$document$spl2, uid, doc; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -102,6 +105,7 @@ while (1) { | ||
case 8: | ||
doc = _this.documents[message.document]; | ||
_message$document$spl = message.document.split(':'), _message$document$spl2 = _slicedToArray(_message$document$spl, 2), uid = _message$document$spl2[1]; | ||
doc = _this.documents[uid]; | ||
if (doc) { | ||
_context.next = 11; | ||
_context.next = 12; | ||
break; | ||
@@ -112,14 +116,14 @@ } | ||
case 11: | ||
_context.prev = 11; | ||
_context.next = 14; | ||
case 12: | ||
_context.prev = 12; | ||
_context.next = 15; | ||
return doc.onMessage(message); | ||
case 14: | ||
_context.next = 20; | ||
case 15: | ||
_context.next = 21; | ||
break; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context['catch'](11); | ||
case 17: | ||
_context.prev = 17; | ||
_context.t0 = _context['catch'](12); | ||
@@ -129,3 +133,3 @@ _this.emit('error', _context.t0); | ||
case 20: | ||
case 21: | ||
case 'end': | ||
@@ -135,3 +139,3 @@ return _context.stop(); | ||
} | ||
}, _callee, _this2, [[11, 16]]); | ||
}, _callee, _this2, [[12, 17]]); | ||
})); | ||
@@ -156,5 +160,7 @@ | ||
_this.id = null; | ||
_this.sequence = 1; | ||
_this.connected = false; | ||
_this.operationUid = 1; | ||
_this.documentUid = 1; | ||
transport.on('open', _this.onTransportOpen); | ||
@@ -181,22 +187,18 @@ transport.on('close', _this.onTransportClose); | ||
value: function open(id) { | ||
var _this3 = this; | ||
debug('open', id); | ||
var document = this.documents[id]; | ||
var documents = this.documents, | ||
types = this.types; | ||
// If there's already a document open, return it. But make sure it wasn't in | ||
// the process of closing, otherwise its future messages will be dropped. | ||
if (document) { | ||
document.closing = false; | ||
return document; | ||
} | ||
var uid = this.documentUid++; | ||
var document = new _document2.default({ | ||
types: types, | ||
id: id + ':' + uid, | ||
client: this | ||
}); | ||
var types = this.types; | ||
documents[uid] = document; | ||
document = new _document2.default({ id: id, types: types, client: this }); | ||
this.documents[id] = document; | ||
document.once('close', function () { | ||
delete _this3.documents[id]; | ||
delete documents[uid]; | ||
}); | ||
@@ -208,7 +210,7 @@ | ||
/** | ||
* Wait for all of the client's document's inflight pending to complete. | ||
* Close all of the client's open documents. | ||
*/ | ||
}, { | ||
key: 'settle', | ||
key: 'close', | ||
value: function () { | ||
@@ -222,3 +224,3 @@ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { | ||
promises = Object.values(this.documents).map(function (d) { | ||
return d.settle(); | ||
return d.close(); | ||
}); | ||
@@ -236,6 +238,40 @@ _context2.next = 3; | ||
function settle() { | ||
function close() { | ||
return _ref2.apply(this, arguments); | ||
} | ||
return close; | ||
}() | ||
/** | ||
* Wait for all of the client's document's inflight pending to complete. | ||
*/ | ||
}, { | ||
key: 'settle', | ||
value: function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { | ||
var promises; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
promises = Object.values(this.documents).map(function (d) { | ||
return d.settle(); | ||
}); | ||
_context3.next = 3; | ||
return Promise.all(promises); | ||
case 3: | ||
case 'end': | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function settle() { | ||
return _ref3.apply(this, arguments); | ||
} | ||
return settle; | ||
@@ -253,7 +289,7 @@ }() | ||
value: function send(message) { | ||
var _this4 = this; | ||
var _this3 = this; | ||
if (!this.connected && message.action !== 'connect') { | ||
return this.once('connect', function () { | ||
_this4.send(message); | ||
_this3.send(message); | ||
}); | ||
@@ -260,0 +296,0 @@ } |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -85,3 +87,2 @@ | ||
_this.inflight = null; | ||
_this.closing = false; | ||
_this.closed = false; | ||
@@ -103,2 +104,3 @@ _this.subscribed = false; | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var id; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -108,24 +110,16 @@ while (1) { | ||
case 0: | ||
debug('close', this.id); | ||
id = this.id; | ||
this.closing = true; | ||
this.emit('closing'); | ||
_context.next = 5; | ||
debug('close', { id: id }); | ||
_context.next = 4; | ||
return this.settle(); | ||
case 5: | ||
_context.next = 7; | ||
case 4: | ||
_context.next = 6; | ||
return this.unsubscribe(); | ||
case 7: | ||
if (this.closing) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return'); | ||
case 9: | ||
this.client.removeListener('disconnect', this.onClientDisconnect); | ||
@@ -135,3 +129,3 @@ this.closed = true; | ||
case 12: | ||
case 9: | ||
case 'end': | ||
@@ -196,5 +190,4 @@ return _context.stop(); | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
debug('fetch', this.id); | ||
var id = this.id, | ||
version = this.version; | ||
var _options$force = options.force, | ||
@@ -204,8 +197,6 @@ force = _options$force === undefined ? false : _options$force; | ||
debug('fetch', { id: id, options: options }); | ||
if (!this.deferreds.fetch || force) { | ||
this.send({ | ||
action: 'fetch', | ||
document: this.id, | ||
version: this.version | ||
}); | ||
this.send({ action: 'fetch', version: version }); | ||
} | ||
@@ -231,5 +222,4 @@ | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
debug('subscribe', this.id); | ||
var id = this.id, | ||
version = this.version; | ||
var _options$force2 = options.force, | ||
@@ -239,8 +229,6 @@ force = _options$force2 === undefined ? false : _options$force2; | ||
debug('subscribe', { id: id, options: options }); | ||
if (!this.deferreds.subscribe || force) { | ||
this.send({ | ||
action: 'subscribe', | ||
document: this.id, | ||
version: this.version | ||
}); | ||
this.send({ action: 'subscribe', version: version }); | ||
} | ||
@@ -271,17 +259,14 @@ | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
debug('unsubscribe', this.id); | ||
var id = this.id; | ||
var _options$force3 = options.force, | ||
force = _options$force3 === undefined ? false : _options$force3; | ||
debug('unsubscribe', { id: id, options: options }); | ||
// Update the `subscribed` flag optimistically, in case the message errors. | ||
this.subscribed = false; | ||
if (!this.deferreds.unsubscribe || force) { | ||
this.send({ | ||
action: 'unsubscribe', | ||
document: this.id | ||
}); | ||
this.send({ action: 'unsubscribe' }); | ||
} | ||
@@ -306,4 +291,6 @@ | ||
debug('send', this.id, { message: message }); | ||
this.client.send(message); | ||
var id = this.id; | ||
debug('send', { id: id, message: message }); | ||
this.client.send(_extends({}, message, { document: id })); | ||
} | ||
@@ -336,3 +323,3 @@ | ||
debug('submit', id, { operation: operation }); | ||
debug('submit', { id: id, operation: operation }); | ||
@@ -346,3 +333,2 @@ if (type.normalize) { | ||
action: 'submit', | ||
document: id, | ||
data: operation | ||
@@ -382,2 +368,4 @@ | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var id = this.id, | ||
client = this.client; | ||
var _options$force4 = options.force, | ||
@@ -387,3 +375,3 @@ force = _options$force4 === undefined ? false : _options$force4; | ||
if (!this.client.connected) return; | ||
if (!client.connected) return; | ||
if (this.deferreds.submit && !force) return; | ||
@@ -398,3 +386,3 @@ | ||
debug('flush', this.id, { message: message }); | ||
debug('flush', { id: id, message: message }); | ||
@@ -408,3 +396,3 @@ // Since the message could have been an inflight one that got rejected, we | ||
if (message.id == null) { | ||
message.id = this.client.id + ':' + this.client.sequence++; | ||
message.id = client.id + ':' + client.operationUid++; | ||
} | ||
@@ -549,3 +537,3 @@ | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(message) { | ||
var err, action, error; | ||
var id, err, action, error; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
@@ -555,4 +543,7 @@ while (1) { | ||
case 0: | ||
debug('onMessage', this.id, { message: message }); | ||
id = this.id; | ||
debug('onMessage', { id: id, message: message }); | ||
(0, _checkers.checkMessage)(message); | ||
@@ -571,41 +562,41 @@ | ||
_context4.t0 = action; | ||
_context4.next = _context4.t0 === 'broadcast' ? 8 : _context4.t0 === 'fetch' ? 11 : _context4.t0 === 'submit' ? 14 : _context4.t0 === 'subscribe' ? 17 : _context4.t0 === 'unsubscribe' ? 20 : 23; | ||
_context4.next = _context4.t0 === 'broadcast' ? 9 : _context4.t0 === 'fetch' ? 12 : _context4.t0 === 'submit' ? 15 : _context4.t0 === 'subscribe' ? 18 : _context4.t0 === 'unsubscribe' ? 21 : 24; | ||
break; | ||
case 8: | ||
_context4.next = 10; | ||
case 9: | ||
_context4.next = 11; | ||
return this.onBroadcast(err, message); | ||
case 10: | ||
case 11: | ||
return _context4.abrupt('return', _context4.sent); | ||
case 11: | ||
_context4.next = 13; | ||
case 12: | ||
_context4.next = 14; | ||
return this.onFetch(err, message); | ||
case 13: | ||
case 14: | ||
return _context4.abrupt('return', _context4.sent); | ||
case 14: | ||
_context4.next = 16; | ||
case 15: | ||
_context4.next = 17; | ||
return this.onSubmit(err, message); | ||
case 16: | ||
case 17: | ||
return _context4.abrupt('return', _context4.sent); | ||
case 17: | ||
_context4.next = 19; | ||
case 18: | ||
_context4.next = 20; | ||
return this.onSubscribe(err, message); | ||
case 19: | ||
case 20: | ||
return _context4.abrupt('return', _context4.sent); | ||
case 20: | ||
_context4.next = 22; | ||
case 21: | ||
_context4.next = 23; | ||
return this.onUnsubscribe(err, message); | ||
case 22: | ||
case 23: | ||
return _context4.abrupt('return', _context4.sent); | ||
case 23: | ||
case 24: | ||
case 'end': | ||
@@ -612,0 +603,0 @@ return _context4.stop(); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -110,5 +112,5 @@ | ||
/** | ||
* Unsubscribe from a `document`. | ||
* Unsubscribe from a document by `id`. | ||
* | ||
* @param {String} document | ||
* @param {String} id | ||
*/ | ||
@@ -118,10 +120,10 @@ | ||
key: 'unsubscribe', | ||
value: function unsubscribe(document) { | ||
value: function unsubscribe(id) { | ||
var subscriptions = this.subscriptions; | ||
var sub = subscriptions[document]; | ||
var sub = subscriptions[id]; | ||
if (!sub) return; | ||
sub.push(null); | ||
delete subscriptions[document]; | ||
delete subscriptions[id]; | ||
} | ||
@@ -138,3 +140,5 @@ | ||
value: function send(message) { | ||
debug('send', this.id, { message: message }); | ||
var id = this.id; | ||
debug('send', { id: id, message: message }); | ||
this.transport.write(message); | ||
@@ -144,5 +148,3 @@ } | ||
/** | ||
* Send a connect message to the client for a `document`. | ||
* | ||
* @param {String} document | ||
* Send a connect message to the client. | ||
*/ | ||
@@ -152,3 +154,3 @@ | ||
key: 'sendConnect', | ||
value: function sendConnect(document) { | ||
value: function sendConnect() { | ||
this.send({ | ||
@@ -271,2 +273,3 @@ action: 'connect', | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(message) { | ||
var id, server; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -276,56 +279,59 @@ while (1) { | ||
case 0: | ||
debug('onMessage', this.id, { message: message }); | ||
id = this.id, server = this.server; | ||
debug('onMessage', { id: id, message: message }); | ||
(0, _checkers.checkMessage)(message); | ||
_context.prev = 2; | ||
_context.prev = 3; | ||
_context.t0 = message.action; | ||
_context.next = _context.t0 === 'connect' ? 6 : _context.t0 === 'fetch' ? 9 : _context.t0 === 'submit' ? 12 : _context.t0 === 'subscribe' ? 15 : _context.t0 === 'unsubscribe' ? 18 : 21; | ||
_context.next = _context.t0 === 'connect' ? 7 : _context.t0 === 'fetch' ? 10 : _context.t0 === 'submit' ? 13 : _context.t0 === 'subscribe' ? 16 : _context.t0 === 'unsubscribe' ? 19 : 22; | ||
break; | ||
case 6: | ||
_context.next = 8; | ||
case 7: | ||
_context.next = 9; | ||
return this.onMessageConnect(message); | ||
case 8: | ||
case 9: | ||
return _context.abrupt('return', _context.sent); | ||
case 9: | ||
_context.next = 11; | ||
case 10: | ||
_context.next = 12; | ||
return this.onMessageFetch(message); | ||
case 11: | ||
case 12: | ||
return _context.abrupt('return', _context.sent); | ||
case 12: | ||
_context.next = 14; | ||
case 13: | ||
_context.next = 15; | ||
return this.onMessageSubmit(message); | ||
case 14: | ||
case 15: | ||
return _context.abrupt('return', _context.sent); | ||
case 15: | ||
_context.next = 17; | ||
case 16: | ||
_context.next = 18; | ||
return this.onMessageSubscribe(message); | ||
case 17: | ||
case 18: | ||
return _context.abrupt('return', _context.sent); | ||
case 18: | ||
_context.next = 20; | ||
case 19: | ||
_context.next = 21; | ||
return this.onMessageUnsubscribe(message); | ||
case 20: | ||
case 21: | ||
return _context.abrupt('return', _context.sent); | ||
case 21: | ||
_context.next = 28; | ||
case 22: | ||
_context.next = 29; | ||
break; | ||
case 23: | ||
_context.prev = 23; | ||
_context.t1 = _context['catch'](2); | ||
case 24: | ||
_context.prev = 24; | ||
_context.t1 = _context['catch'](3); | ||
this.emit('error', _context.t1); | ||
this.server.emit('error', _context.t1); | ||
server.emit('error', _context.t1); | ||
@@ -340,3 +346,3 @@ this.send(_extends({}, message, { | ||
case 28: | ||
case 29: | ||
case 'end': | ||
@@ -346,3 +352,3 @@ return _context.stop(); | ||
} | ||
}, _callee, this, [[2, 23]]); | ||
}, _callee, this, [[3, 24]]); | ||
})); | ||
@@ -402,3 +408,3 @@ | ||
var _options$action, action, context, server, document, version, ops, snapshot; | ||
var _options$action, action, context, server, document, version, _document$split, _document$split2, id, ops, snapshot; | ||
@@ -412,2 +418,3 @@ return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
document = message.document, version = message.version; | ||
_document$split = document.split(':'), _document$split2 = _slicedToArray(_document$split, 1), id = _document$split2[0]; | ||
ops = []; | ||
@@ -417,22 +424,22 @@ snapshot = void 0; | ||
if (!(version == null)) { | ||
_context3.next = 11; | ||
_context3.next = 12; | ||
break; | ||
} | ||
_context3.next = 8; | ||
return server.findSnapshot(document, { context: context }); | ||
_context3.next = 9; | ||
return server.findSnapshot(id, { context: context }); | ||
case 8: | ||
case 9: | ||
snapshot = _context3.sent; | ||
_context3.next = 14; | ||
_context3.next = 15; | ||
break; | ||
case 11: | ||
_context3.next = 13; | ||
return server.listOperations(document, version, undefined, { context: context }); | ||
case 12: | ||
_context3.next = 14; | ||
return server.listOperations(id, version, undefined, { context: context }); | ||
case 13: | ||
case 14: | ||
ops = _context3.sent; | ||
case 14: | ||
case 15: | ||
@@ -442,3 +449,3 @@ this.sendOperations(document, 'broadcast', ops); | ||
case 16: | ||
case 17: | ||
case 'end': | ||
@@ -469,3 +476,4 @@ return _context3.stop(); | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(message) { | ||
var context, server, document, ops, ack; | ||
var context, server, document, _document$split3, _document$split4, id, ops, ack; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
@@ -477,18 +485,19 @@ while (1) { | ||
document = message.document; | ||
_document$split3 = document.split(':'), _document$split4 = _slicedToArray(_document$split3, 1), id = _document$split4[0]; | ||
ops = void 0; | ||
_context4.prev = 3; | ||
_context4.next = 6; | ||
return server.submit(document, message, { context: context }); | ||
_context4.prev = 4; | ||
_context4.next = 7; | ||
return server.submit(id, message, { context: context }); | ||
case 6: | ||
case 7: | ||
ops = _context4.sent; | ||
_context4.next = 13; | ||
_context4.next = 14; | ||
break; | ||
case 9: | ||
_context4.prev = 9; | ||
_context4.t0 = _context4['catch'](3); | ||
case 10: | ||
_context4.prev = 10; | ||
_context4.t0 = _context4['catch'](4); | ||
if (!(_context4.t0.code !== 'operation_duplicate')) { | ||
_context4.next = 13; | ||
_context4.next = 14; | ||
break; | ||
@@ -499,3 +508,3 @@ } | ||
case 13: | ||
case 14: | ||
@@ -510,3 +519,3 @@ if (ops) { | ||
case 16: | ||
case 17: | ||
case 'end': | ||
@@ -516,3 +525,3 @@ return _context4.stop(); | ||
} | ||
}, _callee4, this, [[3, 9]]); | ||
}, _callee4, this, [[4, 10]]); | ||
})); | ||
@@ -540,3 +549,4 @@ | ||
var context, server, subscriptions, id, document, version, subscription, previous; | ||
var context, server, subscriptions, id, document, version, _document$split5, _document$split6, documentId, subscription, previous; | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
@@ -548,8 +558,9 @@ while (1) { | ||
document = message.document, version = message.version; | ||
_context6.next = 4; | ||
return server.subscribe(document, version, { context: context }); | ||
_document$split5 = document.split(':'), _document$split6 = _slicedToArray(_document$split5, 1), documentId = _document$split6[0]; | ||
_context6.next = 5; | ||
return server.subscribe(documentId, version, { context: context }); | ||
case 4: | ||
case 5: | ||
subscription = _context6.sent; | ||
previous = subscriptions[document]; | ||
previous = subscriptions[documentId]; | ||
@@ -561,3 +572,3 @@ | ||
subscriptions[document] = subscription; | ||
subscriptions[documentId] = subscription; | ||
subscription.on('readable', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { | ||
@@ -602,6 +613,6 @@ var op; | ||
// Call into the fetch handler to fetch the current snapshot or operations. | ||
_context6.next = 11; | ||
_context6.next = 12; | ||
return this.onMessageFetch(message, { action: 'subscribe' }); | ||
case 11: | ||
case 12: | ||
case 'end': | ||
@@ -631,3 +642,4 @@ return _context6.stop(); | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(message) { | ||
var document; | ||
var document, _document$split7, _document$split8, id; | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
@@ -638,7 +650,8 @@ while (1) { | ||
document = message.document; | ||
_document$split7 = document.split(':'), _document$split8 = _slicedToArray(_document$split7, 1), id = _document$split8[0]; | ||
this.unsubscribe(document); | ||
this.unsubscribe(id); | ||
this.sendUnsubscribe(document); | ||
case 3: | ||
case 4: | ||
case 'end': | ||
@@ -645,0 +658,0 @@ return _context7.stop(); |
@@ -76,10 +76,2 @@ 'use strict'; | ||
/** | ||
* An auto-incrementing ID for subscriptions. | ||
* | ||
* @type {Number} | ||
*/ | ||
var subscriptionUid = 0; | ||
/** | ||
* Nexus server. | ||
@@ -129,2 +121,4 @@ * | ||
_this.subscriptionUid = 1; | ||
pubsub.on('publish', function (id, operation) { | ||
@@ -847,3 +841,3 @@ if (typeof id !== 'string') { | ||
subscription = new _stream.Readable({ objectMode: true }); | ||
uid = subscriptionUid++; | ||
uid = this.subscriptionUid++; | ||
@@ -850,0 +844,0 @@ |
{ | ||
"name": "nexus", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
120857
3106