parse 4.0.0-alpha.10 → 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.
package/dist/parse.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.0.0-alpha.10
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.10",
534
+ VERSION: 'js' + "4.0.0-alpha.12",
535
535
  APPLICATION_ID: null,
536
536
  JAVASCRIPT_KEY: null,
537
537
  MASTER_KEY: null,
@@ -1961,6 +1961,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1961
1961
  this.state = CLIENT_STATE.CONNECTING;
1962
1962
  }
1963
1963
  this.socket = new WebSocketImplementation(this.serverURL);
1964
+ this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
1964
1965
 
1965
1966
  // Bind WebSocket callbacks
1966
1967
  this.socket.onopen = function () {
@@ -1969,7 +1970,8 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1969
1970
  this.socket.onmessage = function (event) {
1970
1971
  _this4._handleWebSocketMessage(event);
1971
1972
  };
1972
- this.socket.onclose = function () {
1973
+ this.socket.onclose = function (event) {
1974
+ _this4.socket.closingPromise.resolve(event);
1973
1975
  _this4._handleWebSocketClose();
1974
1976
  };
1975
1977
  this.socket.onerror = function (error) {
@@ -2010,16 +2012,17 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
2010
2012
  * This method will close the WebSocket connection to this LiveQueryClient,
2011
2013
  * cancel the auto reconnect and unsubscribe all subscriptions based on it.
2012
2014
  *
2015
+ * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
2013
2016
  */
2014
2017
  }, {
2015
2018
  key: "close",
2016
- value: function () {
2017
- var _context2;
2019
+ value: function () /*: ?Promise*/{
2020
+ var _this$socket, _this$socket2, _context2;
2018
2021
  if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
2019
2022
  return;
2020
2023
  }
2021
2024
  this.state = CLIENT_STATE.DISCONNECTED;
2022
- this.socket.close();
2025
+ (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
2023
2026
  // Notify each subscription about the close
2024
2027
  var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
2025
2028
  _step;
@@ -2036,6 +2039,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
2036
2039
  }
2037
2040
  this._handleReset();
2038
2041
  this.emit(CLIENT_EMMITER_TYPES.CLOSE);
2042
+ return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
2039
2043
  }
2040
2044
 
2041
2045
  // ensure we start with valid state if connect is called again after close