evg_observable 2.14.59 → 2.14.61

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evg_observable",
3
- "version": "2.14.59",
3
+ "version": "2.14.61",
4
4
  "description": "Alternative fast and light library version - observable.",
5
5
  "main": "src/outLib/index.js",
6
6
  "directories": {
@@ -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 stop;
6
+ private enabled;
7
7
  protected killed: boolean;
8
8
  protected process: boolean;
9
9
  protected trash: ISubscriptionLike[];
@@ -7,7 +7,7 @@ const FilterCollection_1 = require("./FilterCollection");
7
7
  class Observable {
8
8
  value;
9
9
  subs = [];
10
- stop = true;
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.stop = false;
24
+ this.enabled = false;
25
25
  }
26
26
  enable() {
27
- this.stop = true;
27
+ this.enabled = true;
28
28
  }
29
29
  get isEnable() {
30
- return this.stop;
30
+ return this.enabled;
31
31
  }
32
32
  next(value) {
33
33
  if (this.killed)
34
34
  return;
35
- if (!this.stop)
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.stop)
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,21 @@ class Observable {
67
67
  this.subs && !(0, FunctionLibs_1.quickDeleteFromArray)(this.subs, listener);
68
68
  }
69
69
  destroy() {
70
- this.value = null;
71
- this.unsubscribeAll();
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.subs.length = 0;
76
+ return;
77
+ }
78
+ const timer = setInterval(() => {
79
+ if (this.process)
80
+ return;
81
+ clearInterval(timer);
82
+ this.value = null;
83
+ this.subs.length = 0;
84
+ }, 10);
74
85
  }
75
86
  unsubscribeAll() {
76
87
  if (this.killed)
@@ -88,6 +99,8 @@ class Observable {
88
99
  return this.subs.length;
89
100
  }
90
101
  subscribe(observer, errorHandler) {
102
+ if (this.killed)
103
+ return undefined;
91
104
  if (!this.isListener(observer))
92
105
  return undefined;
93
106
  const subscribeObject = new SubscribeObject_1.SubscribeObject(this, false);