@dra2020/baseclient 1.0.76 → 1.0.77
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/baseclient.js +18 -7
- package/dist/baseclient.js.map +1 -1
- package/dist/dataflow/dataflow.d.ts +14 -5
- package/lib/dataflow/dataflow.ts +32 -10
- package/package.json +1 -1
|
@@ -1,24 +1,33 @@
|
|
|
1
|
+
export interface IDataFlow {
|
|
2
|
+
dfid: () => any;
|
|
3
|
+
}
|
|
1
4
|
interface UseItem {
|
|
2
5
|
name?: string;
|
|
3
|
-
df:
|
|
6
|
+
df: IDataFlow;
|
|
4
7
|
id?: any;
|
|
5
8
|
wasstale?: boolean;
|
|
6
9
|
}
|
|
7
10
|
export declare class DataFlow {
|
|
8
11
|
usesList: UseItem[];
|
|
9
12
|
constructor();
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
dfid(): any;
|
|
14
|
+
compute(): void;
|
|
15
|
+
uses(df: IDataFlow, name?: string): void;
|
|
12
16
|
usesStale(): boolean;
|
|
13
17
|
wasStale(name: string): boolean;
|
|
14
18
|
usesRemember(): void;
|
|
15
19
|
ifcompute(): void;
|
|
16
|
-
compute(): void;
|
|
17
20
|
}
|
|
18
21
|
export declare class DataFlowCallback extends DataFlow {
|
|
19
22
|
_value: any;
|
|
20
23
|
_cb: () => any;
|
|
21
24
|
constructor(cb: () => any);
|
|
22
|
-
|
|
25
|
+
dfid(): any;
|
|
26
|
+
}
|
|
27
|
+
export declare class DataFlowStamp extends DataFlow {
|
|
28
|
+
_stamp: number;
|
|
29
|
+
constructor();
|
|
30
|
+
dfid(): any;
|
|
31
|
+
stamp(): void;
|
|
23
32
|
}
|
|
24
33
|
export {};
|
package/lib/dataflow/dataflow.ts
CHANGED
|
@@ -10,10 +10,15 @@
|
|
|
10
10
|
//
|
|
11
11
|
//
|
|
12
12
|
|
|
13
|
+
export interface IDataFlow
|
|
14
|
+
{
|
|
15
|
+
dfid: () => any;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
interface UseItem
|
|
14
19
|
{
|
|
15
20
|
name?: string;
|
|
16
|
-
df:
|
|
21
|
+
df: IDataFlow,
|
|
17
22
|
id?: any,
|
|
18
23
|
wasstale?: boolean,
|
|
19
24
|
}
|
|
@@ -28,9 +33,14 @@ export class DataFlow
|
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
// override in subclass
|
|
31
|
-
|
|
36
|
+
dfid(): any { return null }
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
// override in subclass
|
|
39
|
+
compute(): void
|
|
40
|
+
{
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
uses(df: IDataFlow, name?: string): void
|
|
34
44
|
{
|
|
35
45
|
this.usesList.push({ name: name, df: df });
|
|
36
46
|
}
|
|
@@ -39,7 +49,7 @@ export class DataFlow
|
|
|
39
49
|
{
|
|
40
50
|
let isstale = false;
|
|
41
51
|
this.usesList.forEach(ui => {
|
|
42
|
-
ui.wasstale = ui.id !== ui.df.
|
|
52
|
+
ui.wasstale = ui.id !== ui.df.dfid();
|
|
43
53
|
if (ui.wasstale) isstale = true;
|
|
44
54
|
});
|
|
45
55
|
return isstale;
|
|
@@ -53,7 +63,7 @@ export class DataFlow
|
|
|
53
63
|
|
|
54
64
|
usesRemember(): void
|
|
55
65
|
{
|
|
56
|
-
this.usesList.forEach(ui => { ui.id = ui.df.
|
|
66
|
+
this.usesList.forEach(ui => { ui.id = ui.df.dfid() });
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
ifcompute(): void
|
|
@@ -64,10 +74,6 @@ export class DataFlow
|
|
|
64
74
|
this.compute();
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
|
-
|
|
68
|
-
compute(): void
|
|
69
|
-
{
|
|
70
|
-
}
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
// Takes callback that, eventually, returns non-null. The return value is both the value and the id.
|
|
@@ -83,5 +89,21 @@ export class DataFlowCallback extends DataFlow
|
|
|
83
89
|
this._cb = cb;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
dfid(): any { if (!this._value) this._value = this._cb(); return this._value }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Simple helper that maintains a simple monotonically increasing stamp
|
|
96
|
+
export class DataFlowStamp extends DataFlow
|
|
97
|
+
{
|
|
98
|
+
_stamp: number;
|
|
99
|
+
|
|
100
|
+
constructor()
|
|
101
|
+
{
|
|
102
|
+
super();
|
|
103
|
+
this._stamp = 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
dfid(): any { return this._stamp }
|
|
107
|
+
|
|
108
|
+
stamp(): void { this._stamp++ }
|
|
87
109
|
}
|