evg_observable 1.1.19 → 1.1.20

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": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "Light observable",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/BarushevEA/light-observable-ts#readme",
24
24
  "devDependencies": {
25
- "typescript": "^4.4.2",
25
+ "typescript": "^4.4.3",
26
26
  "@testdeck/mocha": "^0.1.2",
27
- "@types/chai": "^4.2.21",
27
+ "@types/chai": "^4.2.22",
28
28
  "chai": "^4.3.4",
29
- "mocha": "^9.1.1",
29
+ "mocha": "^9.1.2",
30
30
  "nyc": "^15.1.0",
31
31
  "ts-node": "^10.2.1"
32
32
  },
@@ -9,14 +9,11 @@ export declare class SubscribeObject<T> implements ISubscribeObject<T> {
9
9
  private emitByNegativeCondition;
10
10
  private emitByPositiveCondition;
11
11
  private emitMatchCondition;
12
- private isPipePromise;
13
12
  protected _order: number;
14
13
  constructor(observable?: IObserver<T>, listener?: IListener<T>);
15
14
  subscribe(listener: IListener<T>): ISubscriptionLike<T>;
16
15
  unsubscribe(): void;
17
16
  send(value: T): void;
18
- private handlePromiseExecution;
19
- private handleNoPromiseExecution;
20
17
  setOnce(): ISubscribe<T>;
21
18
  unsubscribeByNegative(condition: ICallback<any>): ISubscribe<T>;
22
19
  unsubscribeByPositive(condition: ICallback<any>): ISubscribe<T>;
@@ -27,7 +24,6 @@ export declare class SubscribeObject<T> implements ISubscribeObject<T> {
27
24
  pause(): void;
28
25
  get order(): number;
29
26
  set order(value: number);
30
- likePromise(): ISetup<T>;
31
27
  }
32
28
  export declare class Observable<T> implements IObserver<T> {
33
29
  private value;
@@ -11,7 +11,6 @@ class SubscribeObject {
11
11
  this.emitByNegativeCondition = null;
12
12
  this.emitByPositiveCondition = null;
13
13
  this.emitMatchCondition = null;
14
- this.isPipePromise = false;
15
14
  this._order = 0;
16
15
  this.observable = observable;
17
16
  this.listener = listener;
@@ -28,60 +27,6 @@ class SubscribeObject {
28
27
  }
29
28
  }
30
29
  send(value) {
31
- if (this.isPipePromise) {
32
- this.handlePromiseExecution(value)
33
- .catch(err => console.log(`ERROR: isPipePromise = "true" SubscribeObject.send(${value})`, err));
34
- }
35
- this.handleNoPromiseExecution(value);
36
- }
37
- async handlePromiseExecution(value) {
38
- try {
39
- switch (true) {
40
- case !this.observable:
41
- case !this.listener:
42
- this.unsubscribe();
43
- return;
44
- case this.isListenPaused:
45
- return;
46
- case this.once.isOnce:
47
- this.once.isFinished = true;
48
- this.listener(value);
49
- this.unsubscribe();
50
- break;
51
- case !!this.unsubscribeByNegativeCondition:
52
- if (!await this.unsubscribeByNegativeCondition()) {
53
- this.unsubscribeByNegativeCondition = null;
54
- this.unsubscribe();
55
- return;
56
- }
57
- this.listener(value);
58
- break;
59
- case !!this.unsubscribeByPositiveCondition:
60
- if (await (this.unsubscribeByPositiveCondition())) {
61
- this.unsubscribeByPositiveCondition = null;
62
- this.unsubscribe();
63
- return;
64
- }
65
- this.listener(value);
66
- break;
67
- case !!this.emitByNegativeCondition:
68
- !await this.emitByNegativeCondition() && this.listener(value);
69
- break;
70
- case !!this.emitByPositiveCondition:
71
- await this.emitByPositiveCondition() && this.listener(value);
72
- break;
73
- case !!this.emitMatchCondition:
74
- (await this.emitMatchCondition() === value) && this.listener(value);
75
- break;
76
- default:
77
- this.listener(value);
78
- }
79
- }
80
- catch (err) {
81
- console.log(`ERROR: handlePromiseExecution, SubscribeObject.send(${value})`, err);
82
- }
83
- }
84
- handleNoPromiseExecution(value) {
85
30
  switch (true) {
86
31
  case !this.observable:
87
32
  case !this.listener:
@@ -129,31 +74,31 @@ class SubscribeObject {
129
74
  }
130
75
  unsubscribeByNegative(condition) {
131
76
  if (typeof condition !== "function")
132
- condition = () => true;
77
+ condition = () => false;
133
78
  this.unsubscribeByNegativeCondition = condition;
134
79
  return this;
135
80
  }
136
81
  unsubscribeByPositive(condition) {
137
82
  if (typeof condition !== "function")
138
- condition = () => false;
83
+ condition = () => true;
139
84
  this.unsubscribeByPositiveCondition = condition;
140
85
  return this;
141
86
  }
142
87
  emitByNegative(condition) {
143
88
  if (typeof condition !== "function")
144
- condition = () => false;
89
+ condition = () => true;
145
90
  this.emitByNegativeCondition = condition;
146
91
  return this;
147
92
  }
148
93
  emitByPositive(condition) {
149
94
  if (typeof condition !== "function")
150
- condition = () => true;
95
+ condition = () => false;
151
96
  this.emitByPositiveCondition = condition;
152
97
  return this;
153
98
  }
154
99
  emitMatch(condition) {
155
100
  if (typeof condition !== "function")
156
- condition = () => true;
101
+ condition = () => `ERROR CONDITION TYPE ${typeof condition}, CONTROL STATE ${!this.observable.getValue()}`;
157
102
  this.emitMatchCondition = condition;
158
103
  return this;
159
104
  }
@@ -169,10 +114,6 @@ class SubscribeObject {
169
114
  set order(value) {
170
115
  this._order = value;
171
116
  }
172
- likePromise() {
173
- this.isPipePromise = true;
174
- return this;
175
- }
176
117
  }
177
118
  exports.SubscribeObject = SubscribeObject;
178
119
  class Observable {
@@ -28,7 +28,7 @@ export declare type ISubscriptionLike<T> = {
28
28
  };
29
29
  export declare type ISetup<T> = IUnsubscribeByNegative<T> & IUnsubscribeByPositive<T> & IEmitByNegative<T> & IEmitByPositive<T> & IEmitMatchCondition<T> & IOnce<T> & ISubscribe<T>;
30
30
  export declare type IOrderedSetup<T> = IOrderedUnsubscribeByNegative<T> & IOrderedUnsubscribeByPositive<T> & IOrderedEmitByNegative<T> & IOrderedEmitByPositive<T> & IOrderedEmitMatchCondition<T> & IOrderedOnce<T> & IOrderedSubscribe<T>;
31
- export declare type ISubscribeObject<T> = ISubscriptionLike<T> & IPause & IOrder & ISend<T> & ISetup<T> & IPromise<T>;
31
+ export declare type ISubscribeObject<T> = ISubscriptionLike<T> & IPause & IOrder & ISend<T> & ISetup<T>;
32
32
  export declare type ISubscribeCounter = {
33
33
  size(): number;
34
34
  };
@@ -99,20 +99,3 @@ export declare type IGroup = ICollector & {
99
99
  name: string;
100
100
  order: number;
101
101
  };
102
- export declare type IGroupManager = IDestroy & ISubscribeCounter & {
103
- unsubscribe(subscriptionLike: ISubscriptionLike<any>): void;
104
- unsubscribeGroup(name: string): any;
105
- unsubscribeAll(): void;
106
- addGroup(group: IGroup): any;
107
- getGroup(name: any): IGroup;
108
- };
109
- export declare type IGroupOptions = {
110
- name: string;
111
- subscribers?: IOrderedSubscriptionLike<any>[];
112
- };
113
- export declare type IPromise<T> = {
114
- likePromise(): ISetup<T>;
115
- };
116
- export declare type IOrderedPromise<T> = {
117
- likePromise(): IOrderedSetup<T>;
118
- };