@astral/mobx-query 1.17.0 → 1.17.1

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.
@@ -12,5 +12,5 @@ export declare class SynchronizationService {
12
12
  prototype: BroadcastChannel;
13
13
  });
14
14
  private init;
15
- emit: (keys: Keys) => void;
15
+ emit: (keys: Keys) => Promise<void>;
16
16
  }
@@ -1,3 +1,13 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { when } from 'mobx';
1
11
  export class SynchronizationService {
2
12
  constructor(_statusStorageFactory, _dataStorageFactory, _pollingService, _BroadcastChannel = globalThis.BroadcastChannel) {
3
13
  this._statusStorageFactory = _statusStorageFactory;
@@ -15,10 +25,14 @@ export class SynchronizationService {
15
25
  this._pollingService.restart(data.queryKeyHash);
16
26
  });
17
27
  };
18
- this.emit = (keys) => {
19
- var _a, _b, _c;
20
- (_a = this.broadcastChannel) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(Object.assign(Object.assign({}, keys), { data: (_b = this._dataStorageFactory.getStorage(keys.dataKeyHash)) === null || _b === void 0 ? void 0 : _b.data, statuses: (_c = this._statusStorageFactory.getStorage(keys.statusKeyHash)) === null || _c === void 0 ? void 0 : _c.statuses })));
21
- };
28
+ this.emit = (keys) => __awaiter(this, void 0, void 0, function* () {
29
+ var _a, _b;
30
+ const statusStorage = this._statusStorageFactory.getStorage(keys.statusKeyHash);
31
+ if (statusStorage) {
32
+ yield when(() => !statusStorage.isLoading);
33
+ }
34
+ (_a = this.broadcastChannel) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(Object.assign(Object.assign({}, keys), { data: (_b = this._dataStorageFactory.getStorage(keys.dataKeyHash)) === null || _b === void 0 ? void 0 : _b.data, statuses: statusStorage === null || statusStorage === void 0 ? void 0 : statusStorage.statuses })));
35
+ });
22
36
  if (_BroadcastChannel) {
23
37
  this.broadcastChannel = new _BroadcastChannel('@astral/mobx-query');
24
38
  }
@@ -12,5 +12,5 @@ export declare class SynchronizationService {
12
12
  prototype: BroadcastChannel;
13
13
  });
14
14
  private init;
15
- emit: (keys: Keys) => void;
15
+ emit: (keys: Keys) => Promise<void>;
16
16
  }
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.SynchronizationService = void 0;
13
+ const mobx_1 = require("mobx");
4
14
  class SynchronizationService {
5
15
  constructor(_statusStorageFactory, _dataStorageFactory, _pollingService, _BroadcastChannel = globalThis.BroadcastChannel) {
6
16
  this._statusStorageFactory = _statusStorageFactory;
@@ -18,10 +28,14 @@ class SynchronizationService {
18
28
  this._pollingService.restart(data.queryKeyHash);
19
29
  });
20
30
  };
21
- this.emit = (keys) => {
22
- var _a, _b, _c;
23
- (_a = this.broadcastChannel) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(Object.assign(Object.assign({}, keys), { data: (_b = this._dataStorageFactory.getStorage(keys.dataKeyHash)) === null || _b === void 0 ? void 0 : _b.data, statuses: (_c = this._statusStorageFactory.getStorage(keys.statusKeyHash)) === null || _c === void 0 ? void 0 : _c.statuses })));
24
- };
31
+ this.emit = (keys) => __awaiter(this, void 0, void 0, function* () {
32
+ var _a, _b;
33
+ const statusStorage = this._statusStorageFactory.getStorage(keys.statusKeyHash);
34
+ if (statusStorage) {
35
+ yield (0, mobx_1.when)(() => !statusStorage.isLoading);
36
+ }
37
+ (_a = this.broadcastChannel) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(Object.assign(Object.assign({}, keys), { data: (_b = this._dataStorageFactory.getStorage(keys.dataKeyHash)) === null || _b === void 0 ? void 0 : _b.data, statuses: statusStorage === null || statusStorage === void 0 ? void 0 : statusStorage.statuses })));
38
+ });
25
39
  if (_BroadcastChannel) {
26
40
  this.broadcastChannel = new _BroadcastChannel('@astral/mobx-query');
27
41
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "peerDependencies": {
10
10
  "mobx": "^6.0.0"
11
11
  },
12
- "version": "1.17.0",
12
+ "version": "1.17.1",
13
13
  "author": "Astral.Soft",
14
14
  "license": "MIT",
15
15
  "repository": {