@knotx/data 0.5.1 → 0.5.3

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/index.cjs CHANGED
@@ -47,6 +47,7 @@ class DataManager {
47
47
  __publicField$1(this, "mapVersion$", new rxjs.BehaviorSubject(0));
48
48
  __publicField$1(this, "_patchVersionUpdating", false);
49
49
  __publicField$1(this, "_mapVersionUpdating", false);
50
+ __publicField$1(this, "_scheduler", setTimeout.bind(globalThis));
50
51
  }
51
52
  get isInit() {
52
53
  return this.isInit$.value;
@@ -114,6 +115,9 @@ class DataManager {
114
115
  operators.map(({ dataMap, operations }) => this.applyOperation(dataMap, { type: "batch", operations }))
115
116
  ).subscribe(this.dataMap$);
116
117
  this.dispatch({ type: "batch", operations: initialDataList.map((data) => ({ type: "add", data })), isInit: true });
118
+ this._scheduler(() => {
119
+ this.isInit$.next(true);
120
+ });
117
121
  }
118
122
  getOperations$() {
119
123
  return this.operations$.asObservable();
@@ -266,7 +270,7 @@ class DataManager {
266
270
  }
267
271
  return dataMap;
268
272
  }
269
- updateVersion(operation, scheduler = setTimeout) {
273
+ updateVersion(operation, scheduler = this._scheduler) {
270
274
  if (this.isPatchOperation(operation)) {
271
275
  if (this._patchVersionUpdating) {
272
276
  return;
@@ -287,11 +291,6 @@ class DataManager {
287
291
  this._mapVersionUpdating = false;
288
292
  });
289
293
  }
290
- if (!this.isInit && operation.type === "batch" && operation.isInit) {
291
- scheduler(() => {
292
- this.isInit$.next(true);
293
- });
294
- }
295
294
  }
296
295
  isPatchOperation(operation) {
297
296
  switch (operation.type) {
package/dist/index.d.cts CHANGED
@@ -88,6 +88,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
88
88
  get version(): number;
89
89
  private _patchVersionUpdating;
90
90
  private _mapVersionUpdating;
91
+ private _scheduler;
91
92
  constructor(tag: TTag);
92
93
  getDataList$(): Observable<TData[]>;
93
94
  getDataList(): TData[];
package/dist/index.d.mts CHANGED
@@ -88,6 +88,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
88
88
  get version(): number;
89
89
  private _patchVersionUpdating;
90
90
  private _mapVersionUpdating;
91
+ private _scheduler;
91
92
  constructor(tag: TTag);
92
93
  getDataList$(): Observable<TData[]>;
93
94
  getDataList(): TData[];
package/dist/index.d.ts CHANGED
@@ -88,6 +88,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
88
88
  get version(): number;
89
89
  private _patchVersionUpdating;
90
90
  private _mapVersionUpdating;
91
+ private _scheduler;
91
92
  constructor(tag: TTag);
92
93
  getDataList$(): Observable<TData[]>;
93
94
  getDataList(): TData[];
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ class DataManager {
45
45
  __publicField$1(this, "mapVersion$", new BehaviorSubject(0));
46
46
  __publicField$1(this, "_patchVersionUpdating", false);
47
47
  __publicField$1(this, "_mapVersionUpdating", false);
48
+ __publicField$1(this, "_scheduler", setTimeout.bind(globalThis));
48
49
  }
49
50
  get isInit() {
50
51
  return this.isInit$.value;
@@ -112,6 +113,9 @@ class DataManager {
112
113
  map(({ dataMap, operations }) => this.applyOperation(dataMap, { type: "batch", operations }))
113
114
  ).subscribe(this.dataMap$);
114
115
  this.dispatch({ type: "batch", operations: initialDataList.map((data) => ({ type: "add", data })), isInit: true });
116
+ this._scheduler(() => {
117
+ this.isInit$.next(true);
118
+ });
115
119
  }
116
120
  getOperations$() {
117
121
  return this.operations$.asObservable();
@@ -264,7 +268,7 @@ class DataManager {
264
268
  }
265
269
  return dataMap;
266
270
  }
267
- updateVersion(operation, scheduler = setTimeout) {
271
+ updateVersion(operation, scheduler = this._scheduler) {
268
272
  if (this.isPatchOperation(operation)) {
269
273
  if (this._patchVersionUpdating) {
270
274
  return;
@@ -285,11 +289,6 @@ class DataManager {
285
289
  this._mapVersionUpdating = false;
286
290
  });
287
291
  }
288
- if (!this.isInit && operation.type === "batch" && operation.isInit) {
289
- scheduler(() => {
290
- this.isInit$.next(true);
291
- });
292
- }
293
292
  }
294
293
  isPatchOperation(operation) {
295
294
  switch (operation.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/data",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Data for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/lodash-es": "^4.17.12",
36
- "@knotx/build-config": "0.5.1",
37
- "@knotx/eslint-config": "0.5.1",
38
- "@knotx/typescript-config": "0.5.1"
36
+ "@knotx/build-config": "0.5.3",
37
+ "@knotx/eslint-config": "0.5.3",
38
+ "@knotx/typescript-config": "0.5.3"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "unbuild",