evg_observable 2.14.59 → 2.14.60
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { SubscribeObject } from "./SubscribeObject";
|
|
|
3
3
|
export declare class Observable<T> implements IObserver<T>, IStream<T>, IAddFilter<T> {
|
|
4
4
|
private value;
|
|
5
5
|
protected subs: ISubscribeObject<T>[];
|
|
6
|
-
private
|
|
6
|
+
private enabled;
|
|
7
7
|
protected killed: boolean;
|
|
8
8
|
protected process: boolean;
|
|
9
9
|
protected trash: ISubscriptionLike[];
|
package/src/outLib/Observable.js
CHANGED
|
@@ -7,7 +7,7 @@ const FilterCollection_1 = require("./FilterCollection");
|
|
|
7
7
|
class Observable {
|
|
8
8
|
value;
|
|
9
9
|
subs = [];
|
|
10
|
-
|
|
10
|
+
enabled = true;
|
|
11
11
|
killed = false;
|
|
12
12
|
process = false;
|
|
13
13
|
trash = [];
|
|
@@ -21,18 +21,18 @@ class Observable {
|
|
|
21
21
|
return this.filters;
|
|
22
22
|
}
|
|
23
23
|
disable() {
|
|
24
|
-
this.
|
|
24
|
+
this.enabled = false;
|
|
25
25
|
}
|
|
26
26
|
enable() {
|
|
27
|
-
this.
|
|
27
|
+
this.enabled = true;
|
|
28
28
|
}
|
|
29
29
|
get isEnable() {
|
|
30
|
-
return this.
|
|
30
|
+
return this.enabled;
|
|
31
31
|
}
|
|
32
32
|
next(value) {
|
|
33
33
|
if (this.killed)
|
|
34
34
|
return;
|
|
35
|
-
if (!this.
|
|
35
|
+
if (!this.enabled)
|
|
36
36
|
return;
|
|
37
37
|
if (!this.filters.isEmpty && !this.filters.processChain(value).isOK)
|
|
38
38
|
return;
|
|
@@ -46,7 +46,7 @@ class Observable {
|
|
|
46
46
|
stream(values) {
|
|
47
47
|
if (this.killed)
|
|
48
48
|
return;
|
|
49
|
-
if (!this.
|
|
49
|
+
if (!this.enabled)
|
|
50
50
|
return;
|
|
51
51
|
for (let i = 0; i < values.length; i++)
|
|
52
52
|
this.next(values[i]);
|
|
@@ -67,10 +67,23 @@ class Observable {
|
|
|
67
67
|
this.subs && !(0, FunctionLibs_1.quickDeleteFromArray)(this.subs, listener);
|
|
68
68
|
}
|
|
69
69
|
destroy() {
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
this.subs = null;
|
|
70
|
+
if (this.killed)
|
|
71
|
+
return;
|
|
73
72
|
this.killed = true;
|
|
73
|
+
if (!this.process) {
|
|
74
|
+
this.value = null;
|
|
75
|
+
this.unsubscribeAll();
|
|
76
|
+
this.subs.length = 0;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const timer = setInterval(() => {
|
|
80
|
+
if (this.process)
|
|
81
|
+
return;
|
|
82
|
+
clearInterval(timer);
|
|
83
|
+
this.value = null;
|
|
84
|
+
this.unsubscribeAll();
|
|
85
|
+
this.subs.length = 0;
|
|
86
|
+
}, 10);
|
|
74
87
|
}
|
|
75
88
|
unsubscribeAll() {
|
|
76
89
|
if (this.killed)
|