@knotx/data 0.4.16 → 0.5.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.
- package/dist/index.cjs +10 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !==
|
|
|
27
27
|
class DataManager {
|
|
28
28
|
constructor(tag) {
|
|
29
29
|
this.tag = tag;
|
|
30
|
+
__publicField$1(this, "isInit$", new rxjs.BehaviorSubject(false));
|
|
30
31
|
__publicField$1(this, "operations$", new rxjs.Subject());
|
|
31
32
|
__publicField$1(this, "operationPipes$", new rxjs.BehaviorSubject({
|
|
32
33
|
transform: [],
|
|
@@ -47,6 +48,9 @@ class DataManager {
|
|
|
47
48
|
__publicField$1(this, "_patchVersionUpdating", false);
|
|
48
49
|
__publicField$1(this, "_mapVersionUpdating", false);
|
|
49
50
|
}
|
|
51
|
+
get isInit() {
|
|
52
|
+
return this.isInit$.value;
|
|
53
|
+
}
|
|
50
54
|
get version() {
|
|
51
55
|
return this.patchVersion$.value + this.mapVersion$.value;
|
|
52
56
|
}
|
|
@@ -262,7 +266,7 @@ class DataManager {
|
|
|
262
266
|
}
|
|
263
267
|
return dataMap;
|
|
264
268
|
}
|
|
265
|
-
updateVersion(operation, scheduler =
|
|
269
|
+
updateVersion(operation, scheduler = setTimeout) {
|
|
266
270
|
if (this.isPatchOperation(operation)) {
|
|
267
271
|
if (this._patchVersionUpdating) {
|
|
268
272
|
return;
|
|
@@ -283,6 +287,11 @@ class DataManager {
|
|
|
283
287
|
this._mapVersionUpdating = false;
|
|
284
288
|
});
|
|
285
289
|
}
|
|
290
|
+
if (!this.isInit && operation.type === "batch" && operation.isInit) {
|
|
291
|
+
scheduler(() => {
|
|
292
|
+
this.isInit$.next(true);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
286
295
|
}
|
|
287
296
|
isPatchOperation(operation) {
|
|
288
297
|
switch (operation.type) {
|
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,7 @@ interface DataDraftOperation<T extends IData = IData> {
|
|
|
70
70
|
type DataOperation<T extends IData = IData> = DataAddOperation<T> | DataRemoveOperation<T> | DataUpdateOperation<T> | DataBatchOperation<T> | DataStartDraftOperation<T> | DataCommitDraftOperation<T> | DataDiscardDraftOperation<T> | DataDraftOperation<T>;
|
|
71
71
|
declare class DataManager<TData extends IData = IData, TTag extends string = any> {
|
|
72
72
|
readonly tag: TTag;
|
|
73
|
+
private isInit$;
|
|
73
74
|
private operations$;
|
|
74
75
|
private operationPipes$;
|
|
75
76
|
private drafts$;
|
|
@@ -83,6 +84,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
|
|
|
83
84
|
* 数据版本号,用于标识数据的变化,数据增删时,mapVersion 会递增
|
|
84
85
|
*/
|
|
85
86
|
readonly mapVersion$: BehaviorSubject<number>;
|
|
87
|
+
get isInit(): boolean;
|
|
86
88
|
get version(): number;
|
|
87
89
|
private _patchVersionUpdating;
|
|
88
90
|
private _mapVersionUpdating;
|
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,7 @@ interface DataDraftOperation<T extends IData = IData> {
|
|
|
70
70
|
type DataOperation<T extends IData = IData> = DataAddOperation<T> | DataRemoveOperation<T> | DataUpdateOperation<T> | DataBatchOperation<T> | DataStartDraftOperation<T> | DataCommitDraftOperation<T> | DataDiscardDraftOperation<T> | DataDraftOperation<T>;
|
|
71
71
|
declare class DataManager<TData extends IData = IData, TTag extends string = any> {
|
|
72
72
|
readonly tag: TTag;
|
|
73
|
+
private isInit$;
|
|
73
74
|
private operations$;
|
|
74
75
|
private operationPipes$;
|
|
75
76
|
private drafts$;
|
|
@@ -83,6 +84,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
|
|
|
83
84
|
* 数据版本号,用于标识数据的变化,数据增删时,mapVersion 会递增
|
|
84
85
|
*/
|
|
85
86
|
readonly mapVersion$: BehaviorSubject<number>;
|
|
87
|
+
get isInit(): boolean;
|
|
86
88
|
get version(): number;
|
|
87
89
|
private _patchVersionUpdating;
|
|
88
90
|
private _mapVersionUpdating;
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ interface DataDraftOperation<T extends IData = IData> {
|
|
|
70
70
|
type DataOperation<T extends IData = IData> = DataAddOperation<T> | DataRemoveOperation<T> | DataUpdateOperation<T> | DataBatchOperation<T> | DataStartDraftOperation<T> | DataCommitDraftOperation<T> | DataDiscardDraftOperation<T> | DataDraftOperation<T>;
|
|
71
71
|
declare class DataManager<TData extends IData = IData, TTag extends string = any> {
|
|
72
72
|
readonly tag: TTag;
|
|
73
|
+
private isInit$;
|
|
73
74
|
private operations$;
|
|
74
75
|
private operationPipes$;
|
|
75
76
|
private drafts$;
|
|
@@ -83,6 +84,7 @@ declare class DataManager<TData extends IData = IData, TTag extends string = any
|
|
|
83
84
|
* 数据版本号,用于标识数据的变化,数据增删时,mapVersion 会递增
|
|
84
85
|
*/
|
|
85
86
|
readonly mapVersion$: BehaviorSubject<number>;
|
|
87
|
+
get isInit(): boolean;
|
|
86
88
|
get version(): number;
|
|
87
89
|
private _patchVersionUpdating;
|
|
88
90
|
private _mapVersionUpdating;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash-es';
|
|
2
|
-
import {
|
|
2
|
+
import { BehaviorSubject, Subject, pipe } from 'rxjs';
|
|
3
3
|
import { map, distinctUntilChanged, tap, scan } from 'rxjs/operators';
|
|
4
4
|
|
|
5
5
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -25,6 +25,7 @@ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !==
|
|
|
25
25
|
class DataManager {
|
|
26
26
|
constructor(tag) {
|
|
27
27
|
this.tag = tag;
|
|
28
|
+
__publicField$1(this, "isInit$", new BehaviorSubject(false));
|
|
28
29
|
__publicField$1(this, "operations$", new Subject());
|
|
29
30
|
__publicField$1(this, "operationPipes$", new BehaviorSubject({
|
|
30
31
|
transform: [],
|
|
@@ -45,6 +46,9 @@ class DataManager {
|
|
|
45
46
|
__publicField$1(this, "_patchVersionUpdating", false);
|
|
46
47
|
__publicField$1(this, "_mapVersionUpdating", false);
|
|
47
48
|
}
|
|
49
|
+
get isInit() {
|
|
50
|
+
return this.isInit$.value;
|
|
51
|
+
}
|
|
48
52
|
get version() {
|
|
49
53
|
return this.patchVersion$.value + this.mapVersion$.value;
|
|
50
54
|
}
|
|
@@ -260,7 +264,7 @@ class DataManager {
|
|
|
260
264
|
}
|
|
261
265
|
return dataMap;
|
|
262
266
|
}
|
|
263
|
-
updateVersion(operation, scheduler =
|
|
267
|
+
updateVersion(operation, scheduler = setTimeout) {
|
|
264
268
|
if (this.isPatchOperation(operation)) {
|
|
265
269
|
if (this._patchVersionUpdating) {
|
|
266
270
|
return;
|
|
@@ -281,6 +285,11 @@ class DataManager {
|
|
|
281
285
|
this._mapVersionUpdating = false;
|
|
282
286
|
});
|
|
283
287
|
}
|
|
288
|
+
if (!this.isInit && operation.type === "batch" && operation.isInit) {
|
|
289
|
+
scheduler(() => {
|
|
290
|
+
this.isInit$.next(true);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
284
293
|
}
|
|
285
294
|
isPatchOperation(operation) {
|
|
286
295
|
switch (operation.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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.
|
|
37
|
-
"@knotx/eslint-config": "0.
|
|
38
|
-
"@knotx/typescript-config": "0.
|
|
36
|
+
"@knotx/build-config": "0.5.1",
|
|
37
|
+
"@knotx/eslint-config": "0.5.1",
|
|
38
|
+
"@knotx/typescript-config": "0.5.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "unbuild",
|