parse 4.0.0-alpha.11 → 4.0.0-alpha.12

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.0.0-alpha.11
2
+ * Parse JavaScript SDK v4.0.0-alpha.12
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -531,7 +531,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
531
531
  SERVER_AUTH_TOKEN: null,
532
532
  LIVEQUERY_SERVER_URL: null,
533
533
  ENCRYPTED_KEY: null,
534
- VERSION: 'js' + "4.0.0-alpha.11",
534
+ VERSION: 'js' + "4.0.0-alpha.12",
535
535
  APPLICATION_ID: null,
536
536
  JAVASCRIPT_KEY: null,
537
537
  MASTER_KEY: null,
@@ -1926,6 +1926,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1926
1926
  this.state = CLIENT_STATE.CONNECTING;
1927
1927
  }
1928
1928
  this.socket = new WebSocketImplementation(this.serverURL);
1929
+ this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
1929
1930
 
1930
1931
  // Bind WebSocket callbacks
1931
1932
  this.socket.onopen = function () {
@@ -1934,7 +1935,8 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1934
1935
  this.socket.onmessage = function (event) {
1935
1936
  _this4._handleWebSocketMessage(event);
1936
1937
  };
1937
- this.socket.onclose = function () {
1938
+ this.socket.onclose = function (event) {
1939
+ _this4.socket.closingPromise.resolve(event);
1938
1940
  _this4._handleWebSocketClose();
1939
1941
  };
1940
1942
  this.socket.onerror = function (error) {
@@ -1975,16 +1977,17 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1975
1977
  * This method will close the WebSocket connection to this LiveQueryClient,
1976
1978
  * cancel the auto reconnect and unsubscribe all subscriptions based on it.
1977
1979
  *
1980
+ * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
1978
1981
  */
1979
1982
  }, {
1980
1983
  key: "close",
1981
- value: function () {
1982
- var _context2;
1984
+ value: function () /*: ?Promise*/{
1985
+ var _this$socket, _this$socket2, _context2;
1983
1986
  if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
1984
1987
  return;
1985
1988
  }
1986
1989
  this.state = CLIENT_STATE.DISCONNECTED;
1987
- this.socket.close();
1990
+ (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
1988
1991
  // Notify each subscription about the close
1989
1992
  var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
1990
1993
  _step;
@@ -2001,6 +2004,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
2001
2004
  }
2002
2005
  this._handleReset();
2003
2006
  this.emit(CLIENT_EMMITER_TYPES.CLOSE);
2007
+ return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
2004
2008
  }
2005
2009
 
2006
2010
  // ensure we start with valid state if connect is called again after close
@@ -16847,8 +16851,8 @@ module.exports = /*#__PURE__*/function () {
16847
16851
  wx.onSocketMessage(function (msg) {
16848
16852
  _this.onmessage(msg);
16849
16853
  });
16850
- wx.onSocketClose(function () {
16851
- _this.onclose();
16854
+ wx.onSocketClose(function (event) {
16855
+ _this.onclose(event);
16852
16856
  });
16853
16857
  wx.onSocketError(function (error) {
16854
16858
  _this.onerror(error);