parse 5.1.0-alpha.3 → 5.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -187,7 +187,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
187
187
  SERVER_AUTH_TOKEN: null,
188
188
  LIVEQUERY_SERVER_URL: null,
189
189
  ENCRYPTED_KEY: null,
190
- VERSION: 'js' + "5.1.0-alpha.3",
190
+ VERSION: 'js' + "5.1.0-alpha.4",
191
191
  APPLICATION_ID: null,
192
192
  JAVASCRIPT_KEY: null,
193
193
  MASTER_KEY: null,
@@ -13,6 +13,7 @@ _Object$defineProperty(exports, "__esModule", {
13
13
  exports.default = void 0;
14
14
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
15
15
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
16
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
16
17
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
17
18
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
18
19
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
@@ -79,10 +80,10 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
79
80
  };
80
81
  }
81
82
  function _unsupportedIterableToArray(o, minLen) {
82
- var _context6;
83
+ var _context7;
83
84
  if (!o) return;
84
85
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
85
- var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
86
+ var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
86
87
  if (n === "Object" && o.constructor) n = o.constructor.name;
87
88
  if (n === "Map" || n === "Set") return _Array$from(o);
88
89
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
@@ -199,6 +200,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
199
200
  * @param {string} options.installationId (optional)
200
201
  */
201
202
  function LiveQueryClient(_ref) {
203
+ var _this = this;
202
204
  var applicationId = _ref.applicationId,
203
205
  serverURL = _ref.serverURL,
204
206
  javascriptKey = _ref.javascriptKey,
@@ -239,8 +241,16 @@ var LiveQueryClient = /*#__PURE__*/function () {
239
241
  this.state = CLIENT_STATE.INITIALIZED;
240
242
  var EventEmitter = _CoreManager.default.getEventEmitter();
241
243
  this.emitter = new EventEmitter();
242
- this.on = this.emitter.on;
243
- this.emit = this.emitter.emit;
244
+ this.on = function (eventName, listener) {
245
+ return _this.emitter.on(eventName, listener);
246
+ };
247
+ this.emit = function (eventName) {
248
+ var _this$emitter, _context;
249
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
250
+ args[_key - 1] = arguments[_key];
251
+ }
252
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, (0, _concat.default)(_context = [eventName]).call(_context, args));
253
+ };
244
254
  // adding listener so process does not crash
245
255
  // best practice is for developer to register their own listener
246
256
  this.on('error', function () {});
@@ -270,7 +280,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
270
280
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
271
281
  var _queryJSON$keys,
272
282
  _queryJSON$watch,
273
- _this = this;
283
+ _this2 = this;
274
284
  if (!query) {
275
285
  return;
276
286
  }
@@ -296,7 +306,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
296
306
  this.subscriptions.set(this.requestId, subscription);
297
307
  this.requestId += 1;
298
308
  this.connectPromise.then(function () {
299
- _this.socket.send((0, _stringify.default)(subscribeRequest));
309
+ _this2.socket.send((0, _stringify.default)(subscribeRequest));
300
310
  }).catch(function (error) {
301
311
  subscription.subscribePromise.reject(error);
302
312
  });
@@ -312,7 +322,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
312
322
  }, {
313
323
  key: "unsubscribe",
314
324
  value: function (subscription /*: Object*/) /*: ?Promise*/{
315
- var _this2 = this;
325
+ var _this3 = this;
316
326
  if (!subscription) {
317
327
  return;
318
328
  }
@@ -321,7 +331,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
321
331
  requestId: subscription.id
322
332
  };
323
333
  return this.connectPromise.then(function () {
324
- return _this2.socket.send((0, _stringify.default)(unsubscribeRequest));
334
+ return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
325
335
  }).then(function () {
326
336
  return subscription.unsubscribePromise;
327
337
  });
@@ -335,7 +345,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
335
345
  }, {
336
346
  key: "open",
337
347
  value: function () {
338
- var _this3 = this;
348
+ var _this4 = this;
339
349
  var WebSocketImplementation = _CoreManager.default.getWebSocketController();
340
350
  if (!WebSocketImplementation) {
341
351
  this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
@@ -349,25 +359,25 @@ var LiveQueryClient = /*#__PURE__*/function () {
349
359
 
350
360
  // Bind WebSocket callbacks
351
361
  this.socket.onopen = function () {
352
- _this3._handleWebSocketOpen();
362
+ _this4._handleWebSocketOpen();
353
363
  };
354
364
  this.socket.onmessage = function (event) {
355
- _this3._handleWebSocketMessage(event);
365
+ _this4._handleWebSocketMessage(event);
356
366
  };
357
367
  this.socket.onclose = function (event) {
358
- _this3.socket.closingPromise.resolve(event);
359
- _this3._handleWebSocketClose();
368
+ _this4.socket.closingPromise.resolve(event);
369
+ _this4._handleWebSocketClose();
360
370
  };
361
371
  this.socket.onerror = function (error) {
362
- _this3._handleWebSocketError(error);
372
+ _this4._handleWebSocketError(error);
363
373
  };
364
374
  }
365
375
  }, {
366
376
  key: "resubscribe",
367
377
  value: function () {
368
- var _context,
369
- _this4 = this;
370
- (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
378
+ var _context2,
379
+ _this5 = this;
380
+ (0, _forEach.default)(_context2 = this.subscriptions).call(_context2, function (subscription, requestId) {
371
381
  var query = subscription.query;
372
382
  var queryJSON = query.toJSON();
373
383
  var where = queryJSON.where;
@@ -386,8 +396,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
386
396
  if (sessionToken) {
387
397
  subscribeRequest.sessionToken = sessionToken;
388
398
  }
389
- _this4.connectPromise.then(function () {
390
- _this4.socket.send((0, _stringify.default)(subscribeRequest));
399
+ _this5.connectPromise.then(function () {
400
+ _this5.socket.send((0, _stringify.default)(subscribeRequest));
391
401
  });
392
402
  });
393
403
  }
@@ -401,14 +411,14 @@ var LiveQueryClient = /*#__PURE__*/function () {
401
411
  }, {
402
412
  key: "close",
403
413
  value: function () /*: ?Promise*/{
404
- var _this$socket, _this$socket2, _context2;
414
+ var _this$socket, _this$socket2, _context3;
405
415
  if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
406
416
  return;
407
417
  }
408
418
  this.state = CLIENT_STATE.DISCONNECTED;
409
419
  (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
410
420
  // Notify each subscription about the close
411
- var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
421
+ var _iterator = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
412
422
  _step;
413
423
  try {
414
424
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -555,14 +565,14 @@ var LiveQueryClient = /*#__PURE__*/function () {
555
565
  }, {
556
566
  key: "_handleWebSocketClose",
557
567
  value: function () {
558
- var _context3;
568
+ var _context4;
559
569
  if (this.state === CLIENT_STATE.DISCONNECTED) {
560
570
  return;
561
571
  }
562
572
  this.state = CLIENT_STATE.CLOSED;
563
573
  this.emit(CLIENT_EMMITER_TYPES.CLOSE);
564
574
  // Notify each subscription about the close
565
- var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
575
+ var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
566
576
  _step2;
567
577
  try {
568
578
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -579,9 +589,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
579
589
  }, {
580
590
  key: "_handleWebSocketError",
581
591
  value: function (error /*: any*/) {
582
- var _context4;
592
+ var _context5;
583
593
  this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
584
- var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
594
+ var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context5 = this.subscriptions).call(_context5)),
585
595
  _step3;
586
596
  try {
587
597
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
@@ -598,8 +608,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
598
608
  }, {
599
609
  key: "_handleReconnect",
600
610
  value: function () {
601
- var _context5,
602
- _this5 = this;
611
+ var _context6,
612
+ _this6 = this;
603
613
  // if closed or currently reconnecting we stop attempting to reconnect
604
614
  if (this.state === CLIENT_STATE.DISCONNECTED) {
605
615
  return;
@@ -615,11 +625,11 @@ var LiveQueryClient = /*#__PURE__*/function () {
615
625
  if (this.reconnectHandle) {
616
626
  clearTimeout(this.reconnectHandle);
617
627
  }
618
- this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
619
- _this5.attempts++;
620
- _this5.connectPromise = (0, _promiseUtils.resolvingPromise)();
621
- _this5.open();
622
- }).call(_context5, this), time);
628
+ this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context6 = function () {
629
+ _this6.attempts++;
630
+ _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
631
+ _this6.open();
632
+ }).call(_context6, this), time);
623
633
  }
624
634
  }]);
625
635
  return LiveQueryClient;
@@ -6,6 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
9
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
10
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
11
12
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
@@ -99,6 +100,7 @@ var Subscription = /*#__PURE__*/function () {
99
100
  * @param {string} sessionToken - optional session token
100
101
  */
101
102
  function Subscription(id, query, sessionToken) {
103
+ var _this = this;
102
104
  (0, _classCallCheck2.default)(this, Subscription);
103
105
  this.id = id;
104
106
  this.query = query;
@@ -108,8 +110,16 @@ var Subscription = /*#__PURE__*/function () {
108
110
  this.subscribed = false;
109
111
  var EventEmitter = _CoreManager.default.getEventEmitter();
110
112
  this.emitter = new EventEmitter();
111
- this.on = this.emitter.on;
112
- this.emit = this.emitter.emit;
113
+ this.on = function (eventName, listener) {
114
+ return _this.emitter.on(eventName, listener);
115
+ };
116
+ this.emit = function (eventName) {
117
+ var _this$emitter, _context;
118
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
119
+ args[_key - 1] = arguments[_key];
120
+ }
121
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, (0, _concat.default)(_context = [eventName]).call(_context, args));
122
+ };
113
123
  // adding listener so process does not crash
114
124
  // best practice is for developer to register their own listener
115
125
  this.on('error', function () {});
@@ -123,10 +133,10 @@ var Subscription = /*#__PURE__*/function () {
123
133
  (0, _createClass2.default)(Subscription, [{
124
134
  key: "unsubscribe",
125
135
  value: function () /*: Promise*/{
126
- var _this = this;
136
+ var _this2 = this;
127
137
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
128
- _this.emit('close');
129
- return liveQueryClient.unsubscribe(_this);
138
+ _this2.emit('close');
139
+ return liveQueryClient.unsubscribe(_this2);
130
140
  });
131
141
  }
132
142
  }]);
@@ -6,9 +6,10 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
10
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
9
11
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
10
12
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
12
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
13
14
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
14
15
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
@@ -52,12 +53,20 @@ function getLiveQueryClient() /*: Promise<LiveQueryClient>*/{
52
53
  */
53
54
  var LiveQuery = /*#__PURE__*/function () {
54
55
  function LiveQuery() {
56
+ var _this = this;
55
57
  (0, _classCallCheck2.default)(this, LiveQuery);
56
58
  var EventEmitter = _CoreManager.default.getEventEmitter();
57
59
  this.emitter = new EventEmitter();
58
- this.on = this.emitter.on;
59
- this.emit = this.emitter.emit;
60
-
60
+ this.on = function (eventName, listener) {
61
+ return _this.emitter.on(eventName, listener);
62
+ };
63
+ this.emit = function (eventName) {
64
+ var _this$emitter, _context;
65
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
66
+ args[_key - 1] = arguments[_key];
67
+ }
68
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, (0, _concat.default)(_context = [eventName]).call(_context, args));
69
+ };
61
70
  // adding listener so process does not crash
62
71
  // best practice is for developer to register their own listener
63
72
  this.on('error', function () {});
@@ -72,17 +81,17 @@ var LiveQuery = /*#__PURE__*/function () {
72
81
  value: function () {
73
82
  var _open = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
74
83
  var liveQueryClient;
75
- return _regenerator.default.wrap(function (_context) {
76
- while (1) switch (_context.prev = _context.next) {
84
+ return _regenerator.default.wrap(function (_context2) {
85
+ while (1) switch (_context2.prev = _context2.next) {
77
86
  case 0:
78
- _context.next = 2;
87
+ _context2.next = 2;
79
88
  return getLiveQueryClient();
80
89
  case 2:
81
- liveQueryClient = _context.sent;
90
+ liveQueryClient = _context2.sent;
82
91
  liveQueryClient.open();
83
92
  case 4:
84
93
  case "end":
85
- return _context.stop();
94
+ return _context2.stop();
86
95
  }
87
96
  }, _callee);
88
97
  }));
@@ -103,17 +112,17 @@ var LiveQuery = /*#__PURE__*/function () {
103
112
  value: function () {
104
113
  var _close = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
105
114
  var liveQueryClient;
106
- return _regenerator.default.wrap(function (_context2) {
107
- while (1) switch (_context2.prev = _context2.next) {
115
+ return _regenerator.default.wrap(function (_context3) {
116
+ while (1) switch (_context3.prev = _context3.next) {
108
117
  case 0:
109
- _context2.next = 2;
118
+ _context3.next = 2;
110
119
  return getLiveQueryClient();
111
120
  case 2:
112
- liveQueryClient = _context2.sent;
121
+ liveQueryClient = _context3.sent;
113
122
  liveQueryClient.close();
114
123
  case 4:
115
124
  case "end":
116
- return _context2.stop();
125
+ return _context3.stop();
117
126
  }
118
127
  }, _callee2);
119
128
  }));
@@ -135,26 +144,26 @@ var DefaultLiveQueryController = {
135
144
  getDefaultLiveQueryClient: function () /*: Promise<LiveQueryClient>*/{
136
145
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
137
146
  var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey, LiveQuery;
138
- return _regenerator.default.wrap(function (_context3) {
139
- while (1) switch (_context3.prev = _context3.next) {
147
+ return _regenerator.default.wrap(function (_context4) {
148
+ while (1) switch (_context4.prev = _context4.next) {
140
149
  case 0:
141
150
  if (!defaultLiveQueryClient) {
142
- _context3.next = 2;
151
+ _context4.next = 2;
143
152
  break;
144
153
  }
145
- return _context3.abrupt("return", defaultLiveQueryClient);
154
+ return _context4.abrupt("return", defaultLiveQueryClient);
146
155
  case 2:
147
- _context3.next = 4;
156
+ _context4.next = 4;
148
157
  return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
149
158
  case 4:
150
- _yield$Promise$all = _context3.sent;
159
+ _yield$Promise$all = _context4.sent;
151
160
  _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
152
161
  currentUser = _yield$Promise$all2[0];
153
162
  installationId = _yield$Promise$all2[1];
154
163
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
155
164
  liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
156
165
  if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
157
- _context3.next = 12;
166
+ _context4.next = 12;
158
167
  break;
159
168
  }
160
169
  throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
@@ -188,10 +197,10 @@ var DefaultLiveQueryController = {
188
197
  defaultLiveQueryClient.on('close', function () {
189
198
  LiveQuery.emit('close');
190
199
  });
191
- return _context3.abrupt("return", defaultLiveQueryClient);
200
+ return _context4.abrupt("return", defaultLiveQueryClient);
192
201
  case 22:
193
202
  case "end":
194
- return _context3.stop();
203
+ return _context4.stop();
195
204
  }
196
205
  }, _callee3);
197
206
  }))();
@@ -183,7 +183,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
183
183
  SERVER_AUTH_TOKEN: null,
184
184
  LIVEQUERY_SERVER_URL: null,
185
185
  ENCRYPTED_KEY: null,
186
- VERSION: 'js' + "5.1.0-alpha.3",
186
+ VERSION: 'js' + "5.1.0-alpha.4",
187
187
  APPLICATION_ID: null,
188
188
  JAVASCRIPT_KEY: null,
189
189
  MASTER_KEY: null,
@@ -161,8 +161,8 @@ class LiveQueryClient {
161
161
  this.state = CLIENT_STATE.INITIALIZED;
162
162
  const EventEmitter = _CoreManager.default.getEventEmitter();
163
163
  this.emitter = new EventEmitter();
164
- this.on = this.emitter.on;
165
- this.emit = this.emitter.emit;
164
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
165
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
166
166
  // adding listener so process does not crash
167
167
  // best practice is for developer to register their own listener
168
168
  this.on('error', () => {});
@@ -108,8 +108,8 @@ class Subscription {
108
108
  this.subscribed = false;
109
109
  const EventEmitter = _CoreManager.default.getEventEmitter();
110
110
  this.emitter = new EventEmitter();
111
- this.on = this.emitter.on;
112
- this.emit = this.emitter.emit;
111
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
112
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
113
113
  // adding listener so process does not crash
114
114
  // best practice is for developer to register their own listener
115
115
  this.on('error', () => {});
@@ -50,9 +50,8 @@ class LiveQuery {
50
50
  constructor() {
51
51
  const EventEmitter = _CoreManager.default.getEventEmitter();
52
52
  this.emitter = new EventEmitter();
53
- this.on = this.emitter.on;
54
- this.emit = this.emitter.emit;
55
-
53
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
54
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
56
55
  // adding listener so process does not crash
57
56
  // best practice is for developer to register their own listener
58
57
  this.on('error', () => {});
@@ -12,7 +12,7 @@ var config = {
12
12
  SERVER_AUTH_TOKEN: null,
13
13
  LIVEQUERY_SERVER_URL: null,
14
14
  ENCRYPTED_KEY: null,
15
- VERSION: 'js' + "5.1.0-alpha.3",
15
+ VERSION: 'js' + "5.1.0-alpha.4",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,
@@ -55,6 +55,7 @@ var generateInterval = function (k) {
55
55
  };
56
56
  var LiveQueryClient = function () {
57
57
  function LiveQueryClient(_ref) {
58
+ var _this = this;
58
59
  var applicationId = _ref.applicationId,
59
60
  serverURL = _ref.serverURL,
60
61
  javascriptKey = _ref.javascriptKey,
@@ -81,8 +82,16 @@ var LiveQueryClient = function () {
81
82
  this.state = CLIENT_STATE.INITIALIZED;
82
83
  var EventEmitter = _CoreManager.default.getEventEmitter();
83
84
  this.emitter = new EventEmitter();
84
- this.on = this.emitter.on;
85
- this.emit = this.emitter.emit;
85
+ this.on = function (eventName, listener) {
86
+ return _this.emitter.on(eventName, listener);
87
+ };
88
+ this.emit = function (eventName) {
89
+ var _this$emitter;
90
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
91
+ args[_key - 1] = arguments[_key];
92
+ }
93
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, [eventName].concat(args));
94
+ };
86
95
  this.on('error', function () {});
87
96
  }
88
97
  (0, _createClass2.default)(LiveQueryClient, [{
@@ -95,7 +104,7 @@ var LiveQueryClient = function () {
95
104
  value: function (query, sessionToken) {
96
105
  var _queryJSON$keys,
97
106
  _queryJSON$watch,
98
- _this = this;
107
+ _this2 = this;
99
108
  if (!query) {
100
109
  return;
101
110
  }
@@ -121,7 +130,7 @@ var LiveQueryClient = function () {
121
130
  this.subscriptions.set(this.requestId, subscription);
122
131
  this.requestId += 1;
123
132
  this.connectPromise.then(function () {
124
- _this.socket.send(JSON.stringify(subscribeRequest));
133
+ _this2.socket.send(JSON.stringify(subscribeRequest));
125
134
  }).catch(function (error) {
126
135
  subscription.subscribePromise.reject(error);
127
136
  });
@@ -130,7 +139,7 @@ var LiveQueryClient = function () {
130
139
  }, {
131
140
  key: "unsubscribe",
132
141
  value: function (subscription) {
133
- var _this2 = this;
142
+ var _this3 = this;
134
143
  if (!subscription) {
135
144
  return;
136
145
  }
@@ -139,7 +148,7 @@ var LiveQueryClient = function () {
139
148
  requestId: subscription.id
140
149
  };
141
150
  return this.connectPromise.then(function () {
142
- return _this2.socket.send(JSON.stringify(unsubscribeRequest));
151
+ return _this3.socket.send(JSON.stringify(unsubscribeRequest));
143
152
  }).then(function () {
144
153
  return subscription.unsubscribePromise;
145
154
  });
@@ -147,7 +156,7 @@ var LiveQueryClient = function () {
147
156
  }, {
148
157
  key: "open",
149
158
  value: function () {
150
- var _this3 = this;
159
+ var _this4 = this;
151
160
  var WebSocketImplementation = _CoreManager.default.getWebSocketController();
152
161
  if (!WebSocketImplementation) {
153
162
  this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
@@ -159,23 +168,23 @@ var LiveQueryClient = function () {
159
168
  this.socket = new WebSocketImplementation(this.serverURL);
160
169
  this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
161
170
  this.socket.onopen = function () {
162
- _this3._handleWebSocketOpen();
171
+ _this4._handleWebSocketOpen();
163
172
  };
164
173
  this.socket.onmessage = function (event) {
165
- _this3._handleWebSocketMessage(event);
174
+ _this4._handleWebSocketMessage(event);
166
175
  };
167
176
  this.socket.onclose = function (event) {
168
- _this3.socket.closingPromise.resolve(event);
169
- _this3._handleWebSocketClose();
177
+ _this4.socket.closingPromise.resolve(event);
178
+ _this4._handleWebSocketClose();
170
179
  };
171
180
  this.socket.onerror = function (error) {
172
- _this3._handleWebSocketError(error);
181
+ _this4._handleWebSocketError(error);
173
182
  };
174
183
  }
175
184
  }, {
176
185
  key: "resubscribe",
177
186
  value: function () {
178
- var _this4 = this;
187
+ var _this5 = this;
179
188
  this.subscriptions.forEach(function (subscription, requestId) {
180
189
  var query = subscription.query;
181
190
  var queryJSON = query.toJSON();
@@ -195,8 +204,8 @@ var LiveQueryClient = function () {
195
204
  if (sessionToken) {
196
205
  subscribeRequest.sessionToken = sessionToken;
197
206
  }
198
- _this4.connectPromise.then(function () {
199
- _this4.socket.send(JSON.stringify(subscribeRequest));
207
+ _this5.connectPromise.then(function () {
208
+ _this5.socket.send(JSON.stringify(subscribeRequest));
200
209
  });
201
210
  });
202
211
  }
@@ -365,7 +374,7 @@ var LiveQueryClient = function () {
365
374
  }, {
366
375
  key: "_handleReconnect",
367
376
  value: function () {
368
- var _this5 = this;
377
+ var _this6 = this;
369
378
  if (this.state === CLIENT_STATE.DISCONNECTED) {
370
379
  return;
371
380
  }
@@ -375,9 +384,9 @@ var LiveQueryClient = function () {
375
384
  clearTimeout(this.reconnectHandle);
376
385
  }
377
386
  this.reconnectHandle = setTimeout(function () {
378
- _this5.attempts++;
379
- _this5.connectPromise = (0, _promiseUtils.resolvingPromise)();
380
- _this5.open();
387
+ _this6.attempts++;
388
+ _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
389
+ _this6.open();
381
390
  }.bind(this), time);
382
391
  }
383
392
  }]);
@@ -9,6 +9,7 @@ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
9
9
  var _promiseUtils = require("./promiseUtils");
10
10
  var Subscription = function () {
11
11
  function Subscription(id, query, sessionToken) {
12
+ var _this = this;
12
13
  (0, _classCallCheck2.default)(this, Subscription);
13
14
  this.id = id;
14
15
  this.query = query;
@@ -18,17 +19,25 @@ var Subscription = function () {
18
19
  this.subscribed = false;
19
20
  var EventEmitter = _CoreManager.default.getEventEmitter();
20
21
  this.emitter = new EventEmitter();
21
- this.on = this.emitter.on;
22
- this.emit = this.emitter.emit;
22
+ this.on = function (eventName, listener) {
23
+ return _this.emitter.on(eventName, listener);
24
+ };
25
+ this.emit = function (eventName) {
26
+ var _this$emitter;
27
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
28
+ args[_key - 1] = arguments[_key];
29
+ }
30
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, [eventName].concat(args));
31
+ };
23
32
  this.on('error', function () {});
24
33
  }
25
34
  (0, _createClass2.default)(Subscription, [{
26
35
  key: "unsubscribe",
27
36
  value: function () {
28
- var _this = this;
37
+ var _this2 = this;
29
38
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
30
- _this.emit('close');
31
- return liveQueryClient.unsubscribe(_this);
39
+ _this2.emit('close');
40
+ return liveQueryClient.unsubscribe(_this2);
32
41
  });
33
42
  }
34
43
  }]);
@@ -14,11 +14,20 @@ function getLiveQueryClient() {
14
14
  }
15
15
  var LiveQuery = function () {
16
16
  function LiveQuery() {
17
+ var _this = this;
17
18
  (0, _classCallCheck2.default)(this, LiveQuery);
18
19
  var EventEmitter = _CoreManager.default.getEventEmitter();
19
20
  this.emitter = new EventEmitter();
20
- this.on = this.emitter.on;
21
- this.emit = this.emitter.emit;
21
+ this.on = function (eventName, listener) {
22
+ return _this.emitter.on(eventName, listener);
23
+ };
24
+ this.emit = function (eventName) {
25
+ var _this$emitter;
26
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
27
+ args[_key - 1] = arguments[_key];
28
+ }
29
+ return (_this$emitter = _this.emitter).emit.apply(_this$emitter, [eventName].concat(args));
30
+ };
22
31
  this.on('error', function () {});
23
32
  }
24
33
  (0, _createClass2.default)(LiveQuery, [{
@@ -187,7 +187,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
187
187
  SERVER_AUTH_TOKEN: null,
188
188
  LIVEQUERY_SERVER_URL: null,
189
189
  ENCRYPTED_KEY: null,
190
- VERSION: 'js' + "5.1.0-alpha.3",
190
+ VERSION: 'js' + "5.1.0-alpha.4",
191
191
  APPLICATION_ID: null,
192
192
  JAVASCRIPT_KEY: null,
193
193
  MASTER_KEY: null,