evg_observable 1.14.54 → 1.14.56
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/README.md +12 -10
- package/package.json +1 -1
- package/repo/evg_observable.js +1 -1
- package/src/outLib/FilterCollection.d.ts +3 -2
- package/src/outLib/FilterCollection.js +7 -6
- package/src/outLib/Pipe.d.ts +1 -0
- package/src/outLib/Pipe.js +15 -30
- package/src/outLib/SubscribeObject.js +1 -1
- package/src/outLib/Types.d.ts +2 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ features that make it stand out from the rest:
|
|
|
70
70
|
## Observable simple usage
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
|
-
import {Observable} from "evg_observable
|
|
73
|
+
import {Observable} from "evg_observable";
|
|
74
74
|
|
|
75
75
|
const observable$ = new Observable('Some typed data (not only string)');
|
|
76
76
|
|
|
@@ -147,7 +147,7 @@ observable$.destroy(); // all subscribers have automatically unsubscribed
|
|
|
147
147
|
Observable will send a value to the subscriber only once, and the subscriber will unsubscribe.
|
|
148
148
|
|
|
149
149
|
```ts
|
|
150
|
-
import {Observable} from "evg_observable
|
|
150
|
+
import {Observable} from "evg_observable";
|
|
151
151
|
|
|
152
152
|
const observable$ = new Observable('Some typed data (not only string)');
|
|
153
153
|
const listener1 = (value: string) => console.log('listener1:', value);
|
|
@@ -178,7 +178,7 @@ Observable will send a value to the subscriber as long as the condition is negat
|
|
|
178
178
|
subscriber will unsubscribe.
|
|
179
179
|
|
|
180
180
|
```ts
|
|
181
|
-
import {Observable} from "evg_observable
|
|
181
|
+
import {Observable} from "evg_observable";
|
|
182
182
|
|
|
183
183
|
type ISomeData = {
|
|
184
184
|
message: string;
|
|
@@ -222,7 +222,7 @@ Observable will send a value to the subscriber only if the return value of the c
|
|
|
222
222
|
this case, there is no automatic unsubscription.
|
|
223
223
|
|
|
224
224
|
```ts
|
|
225
|
-
import {Observable} from "evg_observable
|
|
225
|
+
import {Observable} from "evg_observable";
|
|
226
226
|
|
|
227
227
|
const observable$ = new Observable('Some typed data (not only string)');
|
|
228
228
|
const listener1 = (value: string) => console.log('listener1:', value);
|
|
@@ -265,7 +265,7 @@ Return Value: An ISetup<string> object.
|
|
|
265
265
|
Usage Example:
|
|
266
266
|
|
|
267
267
|
```ts
|
|
268
|
-
import {Observable} from "evg_observable
|
|
268
|
+
import {Observable} from "evg_observable";
|
|
269
269
|
type IPoint = { x: number, y: number };
|
|
270
270
|
|
|
271
271
|
const rawObject: IPoint = {x: 10, y: 20};
|
|
@@ -290,7 +290,7 @@ Return Value: An ISetup<K> object, where K is the type of data resulting f
|
|
|
290
290
|
Usage Example:
|
|
291
291
|
|
|
292
292
|
```ts
|
|
293
|
-
import {Observable} from "evg_observable
|
|
293
|
+
import {Observable} from "evg_observable";
|
|
294
294
|
type IPoint = { x: number, y: number };
|
|
295
295
|
|
|
296
296
|
const rawObject: IPoint = {x: 10, y: 20};
|
|
@@ -314,7 +314,7 @@ Ordered observable - differs from Observable in that it allows you to emit messa
|
|
|
314
314
|
are the same.
|
|
315
315
|
|
|
316
316
|
```ts
|
|
317
|
-
import {OrderedObservable} from "evg_observable
|
|
317
|
+
import {OrderedObservable} from "evg_observable";
|
|
318
318
|
|
|
319
319
|
const observable$ = new OrderedObservable('Some typed data (not only string)');
|
|
320
320
|
const listener1 = (value: string) => console.log('listener1:', value);
|
|
@@ -360,8 +360,8 @@ observable$.next('SOME DATA');
|
|
|
360
360
|
You can also use the subscriber collector for convenience.
|
|
361
361
|
|
|
362
362
|
```ts
|
|
363
|
-
import {Observable} from "evg_observable
|
|
364
|
-
import {Collector} from "evg_observable
|
|
363
|
+
import {Observable} from "evg_observable";
|
|
364
|
+
import {Collector} from "evg_observable";
|
|
365
365
|
|
|
366
366
|
const collector = new Collector();
|
|
367
367
|
const observable$ = new Observable('Some typed data (not only string)');
|
|
@@ -407,7 +407,7 @@ updates:
|
|
|
407
407
|
|
|
408
408
|
```typescript
|
|
409
409
|
// Import the Observable library
|
|
410
|
-
import {Observable} from "evg_observable
|
|
410
|
+
import {Observable} from "evg_observable";
|
|
411
411
|
|
|
412
412
|
// Constants representing different hair colors
|
|
413
413
|
const HAIR = {
|
|
@@ -554,6 +554,8 @@ payload data in the pipe chain by applying a user callback function.
|
|
|
554
554
|
Here is the syntax:
|
|
555
555
|
|
|
556
556
|
```typescript
|
|
557
|
+
import {Observable} from "evg_observable";
|
|
558
|
+
|
|
557
559
|
const targetObservable$ = new Observable("");
|
|
558
560
|
const targetListener = (num: number) => console.log(num);
|
|
559
561
|
|
package/package.json
CHANGED
package/repo/evg_observable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const s=(s,e)=>s.order>e.order?1:s.order<e.order?-1:0,e=(s,e)=>s.order>e.order?-1:s.order<e.order?1:0;function i(s,e){const i=s.indexOf(e);return-1!==i&&(s[i]=s[s.length-1],s.length=s.length-1,!0)}function t(s){return"next"in s?e=>s.next(e):s}class r{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isNeedUnsubscribe:!1,isAvailable:!1,payload:null}}
|
|
1
|
+
(()=>{"use strict";const s=(s,e)=>s.order>e.order?1:s.order<e.order?-1:0,e=(s,e)=>s.order>e.order?-1:s.order<e.order?1:0;function i(s,e){const i=s.indexOf(e);return-1!==i&&(s[i]=s[s.length-1],s.length=s.length-1,!0)}function t(s){return"next"in s?e=>s.next(e):s}class r{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isNeedUnsubscribe:!1,isAvailable:!1,payload:null}}push(s){return this.chainHandlers.push(s),this}setOnce(){return this.push((s=>{this.listener(s.payload),s.isNeedUnsubscribe=!0}))}unsubscribeByNegative(s){return this.push((e=>{e.isAvailable=!0,s(e.payload)||(e.isNeedUnsubscribe=!0)}))}unsubscribeByPositive(s){return this.push((e=>{e.isAvailable=!0,s(e.payload)&&(e.isNeedUnsubscribe=!0)}))}unsubscribeBy(s){return this.unsubscribeByPositive(s)}emitByNegative(s){return this.push((e=>{s(e.payload)||(e.isAvailable=!0)}))}emitByPositive(s){return this.push((e=>{s(e.payload)&&(e.isAvailable=!0)}))}refine(s){return this.emitByPositive(s)}pushRefiners(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.emitByPositive(s[e]);return this}emitMatch(s){return this.push((e=>{s(e.payload)==e.payload&&(e.isAvailable=!0)}))}switch(){return new n(this)}then(s){return this.push((e=>{e.payload=s(e.payload),e.isAvailable=!0}))}serialize(){return this.push((s=>{s.payload=JSON.stringify(s.payload),s.isAvailable=!0}))}deserialize(){return this.push((s=>{s.payload=JSON.parse(s.payload),s.isAvailable=!0}))}processChain(s){const e=this.chainHandlers,i=this.pipeData;for(let s=0;s<e.length;s++){if(i.isNeedUnsubscribe=!1,i.isAvailable=!1,e[s](i),i.isNeedUnsubscribe)return this.unsubscribe();if(!i.isAvailable)return;if(i.isBreakChain)break}return s(i.payload)}}class n{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}subscribe(s,e){return this.pipe.subscribe(s,e)}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.chainHandlers;return i.push((t=>{t.isAvailable=!0,s(t.payload)&&(t.isBreakChain=!0),e!==i.length||t.isBreakChain||(t.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class h extends r{constructor(s,e){super(),this.errorHandler=(s,e)=>{console.log(`(Unit of SubscribeObject).send(${s}) ERROR:`,e)},this._order=0,this.isPaused=!1,this.isPipe=!1,this.observable=s,this.isPipe=!!e}subscribe(s,e){return this.listener=function(s){if(Array.isArray(s)){const e=[];for(let i=0;i<s.length;i++)e.push(t(s[i]));return s=>{for(let i=0;i<e.length;i++)e[i](s)}}return t(s)}(s),e&&(this.errorHandler=e),this}unsubscribe(){this.observable&&(this.observable.unSubscribe(this),this.observable=null,this.listener=null,this.chainHandlers.length=0)}send(s){try{this.pipeData.payload=s,this.pipeData.isBreakChain=!1,this.processValue(s)}catch(e){this.errorHandler(s,e)}}resume(){this.isPaused=!1}pause(){this.isPaused=!0}get order(){return this._order}set order(s){this._order=s}processValue(s){const e=this.listener;return e?this.observable&&!this.isPaused?this.isPipe?this.processChain(e):e(s):void 0:this.unsubscribe()}}class a{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isAvailable:!1,payload:null},this.response={isOK:!1,payload:void 0}}get isEmpty(){return!this.chainHandlers.length}push(s){return this.chainHandlers.push(s),this}filter(s){return this.push((e=>{s(e.payload)&&(e.isAvailable=!0)}))}pushFilters(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.filter(s[e]);return this}switch(){return new l(this)}processChain(s){const e=this.chainHandlers,i=this.pipeData,t=this.response;t.isOK=!1,t.payload=void 0,i.payload=s,i.isBreakChain=!1;try{for(let s=0;s<e.length;s++){if(i.isAvailable=!1,e[s](i),!i.isAvailable)return t;if(i.isBreakChain)break}}catch(s){return this.errorHandler?this.errorHandler(s,"Filter.processChain ERROR:"):console.log("Filter.processChain ERROR:",s),t}return t.isOK=!0,t.payload=i.payload,t}addErrorHandler(s){this.errorHandler=s}}class l{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.chainHandlers;return i.push((t=>{t.isAvailable=!0,s(t.payload)&&(t.isBreakChain=!0),e!==i.length||t.isBreakChain||(t.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class u{constructor(s){this.value=s,this.listeners=[],this._isEnable=!0,this._isDestroyed=!1,this.isNextProcess=!1,this.listenersForUnsubscribe=[],this.filterCase=new a}addFilter(s){return s&&this.filterCase.addErrorHandler(s),this.filterCase}disable(){this._isEnable=!1}enable(){this._isEnable=!0}get isEnable(){return this._isEnable}next(s){if(!this._isDestroyed&&this._isEnable&&(this.filterCase.isEmpty||this.filterCase.processChain(s).isOK)){this.isNextProcess=!0,this.value=s;for(let e=0;e<this.listeners.length;e++)this.listeners[e].send(s);this.isNextProcess=!1,this.listenersForUnsubscribe.length&&this.handleListenersForUnsubscribe()}}stream(s){if(!this._isDestroyed&&this._isEnable)for(let e=0;e<s.length;e++)this.next(s[e])}handleListenersForUnsubscribe(){const s=this.listenersForUnsubscribe.length;for(let e=0;e<s;e++)this.unSubscribe(this.listenersForUnsubscribe[e]);this.listenersForUnsubscribe.length=0}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&i(this.listeners,s))}destroy(){this.value=null,this.unsubscribeAll(),this.listeners=null,this._isDestroyed=!0}unsubscribeAll(){this._isDestroyed||(this.listeners.length=0)}getValue(){if(!this._isDestroyed)return this.value}size(){return this._isDestroyed?0:this.listeners.length}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new h(this,!1);return this.addObserver(i,s,e),i}addObserver(s,e,i){s.subscribe(e,i),this.listeners.push(s)}isSubsValid(s){return!this._isDestroyed&&!!s}pipe(){if(this._isDestroyed)return;const s=new h(this,!0);return this.listeners.push(s),s}get isDestroyed(){return this._isDestroyed}}class o extends h{constructor(s,e){super(s,e)}get order(){return this._order}set order(s){!this.observable||this.observable&&this.observable.isDestroyed?this._order=void 0:(this._order=s,this.observable.sortByOrder())}subscribe(s,e){return super.subscribe(s,e),this}setOnce(){return super.setOnce()}unsubscribeByNegative(s){return super.unsubscribeByNegative(s)}unsubscribeByPositive(s){return super.unsubscribeByPositive(s)}emitByNegative(s){return super.emitByNegative(s)}emitByPositive(s){return super.emitByPositive(s)}emitMatch(s){return super.emitMatch(s)}}const c=window;c.Observable=u,c.Collector=class{constructor(){this.list=[],this._isDestroyed=!1}collect(...s){this._isDestroyed||this.list.push(...s)}unsubscribe(s){this._isDestroyed||(s?.unsubscribe(),i(this.list,s))}unsubscribeAll(){if(!this._isDestroyed)for(;this.list.length>0;)this.unsubscribe(this.list.pop())}size(){return this._isDestroyed?0:this.list.length}destroy(){this.unsubscribeAll(),this.list.length=0,this.list=0,this._isDestroyed=!0}get isDestroyed(){return this._isDestroyed}},c.OrderedObservable=class extends u{constructor(){super(...arguments),this.sortDirection=s}setAscendingSort(){return this.sortDirection=s,this.sortByOrder()}setDescendingSort(){return this.sortDirection=e,this.sortByOrder()}sortByOrder(){return!this._isDestroyed&&(this.listeners.sort(this.sortDirection),!0)}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new o(this,!1);return this.addObserver(i,s,e),i}pipe(){if(this._isDestroyed)return;const s=new o(this,!0);return this.listeners.push(s),s}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&function(s,e){const i=s.indexOf(e);-1!==i&&s.splice(i,1)}(this.listeners,s))}}})();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ICallback,
|
|
1
|
+
import { ICallback, IErrorCallback, IFilter, IFilterCase, IFilterChainCallback, IFilterPayload, IFilterResponse, IFilterSetup, IFilterSwitch } from "./Types";
|
|
2
2
|
export declare class FilterCollection<T> implements IFilter<T>, IFilterSwitch<T> {
|
|
3
|
-
chainHandlers:
|
|
3
|
+
chainHandlers: IFilterChainCallback[];
|
|
4
4
|
pipeData: IFilterPayload;
|
|
5
5
|
response: IFilterResponse;
|
|
6
6
|
private errorHandler;
|
|
7
7
|
get isEmpty(): boolean;
|
|
8
|
+
private push;
|
|
8
9
|
filter(condition: ICallback<any>): IFilterSetup<T>;
|
|
9
10
|
pushFilters(conditions: ICallback<any>[]): IFilterSetup<T>;
|
|
10
11
|
switch(): FilterSwitchCase<T>;
|
|
@@ -9,13 +9,15 @@ class FilterCollection {
|
|
|
9
9
|
get isEmpty() {
|
|
10
10
|
return !this.chainHandlers.length;
|
|
11
11
|
}
|
|
12
|
+
push(callback) {
|
|
13
|
+
this.chainHandlers.push(callback);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
12
16
|
filter(condition) {
|
|
13
|
-
|
|
14
|
-
this.chainHandlers.push(() => {
|
|
17
|
+
return this.push((data) => {
|
|
15
18
|
if (condition(data.payload))
|
|
16
19
|
data.isAvailable = true;
|
|
17
20
|
});
|
|
18
|
-
return this;
|
|
19
21
|
}
|
|
20
22
|
pushFilters(conditions) {
|
|
21
23
|
if (!Array.isArray(conditions))
|
|
@@ -38,7 +40,7 @@ class FilterCollection {
|
|
|
38
40
|
try {
|
|
39
41
|
for (let i = 0; i < chain.length; i++) {
|
|
40
42
|
data.isAvailable = false;
|
|
41
|
-
chain[i]();
|
|
43
|
+
chain[i](data);
|
|
42
44
|
if (!data.isAvailable)
|
|
43
45
|
return response;
|
|
44
46
|
if (data.isBreakChain)
|
|
@@ -73,9 +75,8 @@ class FilterSwitchCase {
|
|
|
73
75
|
case(condition) {
|
|
74
76
|
this.caseCounter++;
|
|
75
77
|
const id = this.caseCounter;
|
|
76
|
-
const data = this.pipe.pipeData;
|
|
77
78
|
const chain = this.pipe.chainHandlers;
|
|
78
|
-
chain.push(() => {
|
|
79
|
+
chain.push((data) => {
|
|
79
80
|
data.isAvailable = true;
|
|
80
81
|
if (condition(data.payload))
|
|
81
82
|
data.isBreakChain = true;
|
package/src/outLib/Pipe.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare abstract class Pipe<T> implements ISubscribe<T> {
|
|
|
3
3
|
chainHandlers: IChainCallback[];
|
|
4
4
|
pipeData: IPipePayload;
|
|
5
5
|
abstract subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
6
|
+
private push;
|
|
6
7
|
setOnce(): ISubscribe<T>;
|
|
7
8
|
unsubscribeByNegative(condition: ICallback<T>): ISetup<T>;
|
|
8
9
|
unsubscribeByPositive(condition: ICallback<T>): ISetup<T>;
|
package/src/outLib/Pipe.js
CHANGED
|
@@ -4,50 +4,44 @@ exports.SwitchCase = exports.Pipe = void 0;
|
|
|
4
4
|
class Pipe {
|
|
5
5
|
chainHandlers = [];
|
|
6
6
|
pipeData = { isBreakChain: false, isNeedUnsubscribe: false, isAvailable: false, payload: null };
|
|
7
|
+
push(callback) {
|
|
8
|
+
this.chainHandlers.push(callback);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
7
11
|
setOnce() {
|
|
8
|
-
|
|
9
|
-
this.chainHandlers.push(() => {
|
|
12
|
+
return this.push((data) => {
|
|
10
13
|
this.listener(data.payload);
|
|
11
14
|
data.isNeedUnsubscribe = true;
|
|
12
15
|
});
|
|
13
|
-
return this;
|
|
14
16
|
}
|
|
15
17
|
unsubscribeByNegative(condition) {
|
|
16
|
-
|
|
17
|
-
this.chainHandlers.push(() => {
|
|
18
|
+
return this.push((data) => {
|
|
18
19
|
data.isAvailable = true;
|
|
19
20
|
if (!condition(data.payload))
|
|
20
21
|
data.isNeedUnsubscribe = true;
|
|
21
22
|
});
|
|
22
|
-
return this;
|
|
23
23
|
}
|
|
24
24
|
unsubscribeByPositive(condition) {
|
|
25
|
-
|
|
26
|
-
this.chainHandlers.push(() => {
|
|
25
|
+
return this.push((data) => {
|
|
27
26
|
data.isAvailable = true;
|
|
28
27
|
if (condition(data.payload))
|
|
29
28
|
data.isNeedUnsubscribe = true;
|
|
30
29
|
});
|
|
31
|
-
return this;
|
|
32
30
|
}
|
|
33
31
|
unsubscribeBy(condition) {
|
|
34
32
|
return this.unsubscribeByPositive(condition);
|
|
35
33
|
}
|
|
36
34
|
emitByNegative(condition) {
|
|
37
|
-
|
|
38
|
-
this.chainHandlers.push(() => {
|
|
35
|
+
return this.push((data) => {
|
|
39
36
|
if (!condition(data.payload))
|
|
40
37
|
data.isAvailable = true;
|
|
41
38
|
});
|
|
42
|
-
return this;
|
|
43
39
|
}
|
|
44
40
|
emitByPositive(condition) {
|
|
45
|
-
|
|
46
|
-
this.chainHandlers.push(() => {
|
|
41
|
+
return this.push((data) => {
|
|
47
42
|
if (condition(data.payload))
|
|
48
43
|
data.isAvailable = true;
|
|
49
44
|
});
|
|
50
|
-
return this;
|
|
51
45
|
}
|
|
52
46
|
refine(condition) {
|
|
53
47
|
return this.emitByPositive(condition);
|
|
@@ -60,39 +54,31 @@ class Pipe {
|
|
|
60
54
|
return this;
|
|
61
55
|
}
|
|
62
56
|
emitMatch(condition) {
|
|
63
|
-
|
|
64
|
-
this.chainHandlers.push(() => {
|
|
57
|
+
return this.push((data) => {
|
|
65
58
|
if (condition(data.payload) == data.payload)
|
|
66
59
|
data.isAvailable = true;
|
|
67
60
|
});
|
|
68
|
-
return this;
|
|
69
61
|
}
|
|
70
62
|
switch() {
|
|
71
63
|
return new SwitchCase(this);
|
|
72
64
|
}
|
|
73
65
|
then(condition) {
|
|
74
|
-
|
|
75
|
-
this.chainHandlers.push(() => {
|
|
66
|
+
return this.push((data) => {
|
|
76
67
|
data.payload = condition(data.payload);
|
|
77
68
|
data.isAvailable = true;
|
|
78
69
|
});
|
|
79
|
-
return this;
|
|
80
70
|
}
|
|
81
71
|
serialize() {
|
|
82
|
-
|
|
83
|
-
this.chainHandlers.push(() => {
|
|
72
|
+
return this.push((data) => {
|
|
84
73
|
data.payload = JSON.stringify(data.payload);
|
|
85
74
|
data.isAvailable = true;
|
|
86
75
|
});
|
|
87
|
-
return this;
|
|
88
76
|
}
|
|
89
77
|
deserialize() {
|
|
90
|
-
|
|
91
|
-
this.chainHandlers.push(() => {
|
|
78
|
+
return this.push((data) => {
|
|
92
79
|
data.payload = JSON.parse(data.payload);
|
|
93
80
|
data.isAvailable = true;
|
|
94
81
|
});
|
|
95
|
-
return this;
|
|
96
82
|
}
|
|
97
83
|
processChain(listener) {
|
|
98
84
|
const chain = this.chainHandlers;
|
|
@@ -100,7 +86,7 @@ class Pipe {
|
|
|
100
86
|
for (let i = 0; i < chain.length; i++) {
|
|
101
87
|
data.isNeedUnsubscribe = false;
|
|
102
88
|
data.isAvailable = false;
|
|
103
|
-
chain[i]();
|
|
89
|
+
chain[i](data);
|
|
104
90
|
if (data.isNeedUnsubscribe)
|
|
105
91
|
return this.unsubscribe();
|
|
106
92
|
if (!data.isAvailable)
|
|
@@ -125,9 +111,8 @@ class SwitchCase {
|
|
|
125
111
|
case(condition) {
|
|
126
112
|
this.caseCounter++;
|
|
127
113
|
const id = this.caseCounter;
|
|
128
|
-
const data = this.pipe.pipeData;
|
|
129
114
|
const chain = this.pipe.chainHandlers;
|
|
130
|
-
chain.push(() => {
|
|
115
|
+
chain.push((data) => {
|
|
131
116
|
data.isAvailable = true;
|
|
132
117
|
if (condition(data.payload))
|
|
133
118
|
data.isBreakChain = true;
|
package/src/outLib/Types.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ export type IPipePayload = {
|
|
|
132
132
|
isAvailable: boolean;
|
|
133
133
|
payload: any;
|
|
134
134
|
};
|
|
135
|
-
export type IChainCallback = () => void;
|
|
135
|
+
export type IChainCallback = (data: IPipePayload) => void;
|
|
136
136
|
export type IPipeCase<T> = {
|
|
137
137
|
case(condition: ICallback<any>): IPipeCase<T> & ISubscribe<T>;
|
|
138
138
|
pushCases(conditions: ICallback<any>[]): IPipeCase<T> & ISubscribe<T>;
|
|
@@ -159,6 +159,7 @@ export type IFilterPayload = {
|
|
|
159
159
|
isAvailable: boolean;
|
|
160
160
|
payload: any;
|
|
161
161
|
};
|
|
162
|
+
export type IFilterChainCallback = (data: IFilterPayload) => void;
|
|
162
163
|
export type IFilterResponse = {
|
|
163
164
|
isOK: boolean;
|
|
164
165
|
payload: any;
|