evg_observable 1.14.56 → 2.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 +2 -47
- package/package.json +1 -1
- package/repo/evg_observable.js +1 -1
- package/src/outLib/AbstractSwitchCase.d.ts +8 -0
- package/src/outLib/AbstractSwitchCase.js +32 -0
- package/src/outLib/Collector.d.ts +1 -1
- package/src/outLib/Collector.js +7 -7
- package/src/outLib/FilterCollection.d.ts +6 -10
- package/src/outLib/FilterCollection.js +14 -39
- package/src/outLib/Observable.d.ts +6 -6
- package/src/outLib/Observable.js +34 -34
- package/src/outLib/OrderedObservable.js +6 -6
- package/src/outLib/OrderedSubscribeObject.d.ts +1 -6
- package/src/outLib/OrderedSubscribeObject.js +0 -15
- package/src/outLib/Pipe.d.ts +5 -14
- package/src/outLib/Pipe.js +18 -68
- package/src/outLib/SubscribeObject.js +3 -3
- package/src/outLib/Types.d.ts +12 -13
package/README.md
CHANGED
|
@@ -216,46 +216,6 @@ observable$.next({message: "some message3", isNeedUnsubscribe: true});
|
|
|
216
216
|
|
|
217
217
|
Observable will send a value to the listener only if condition returns "true". There is no automatic unsubscription.
|
|
218
218
|
|
|
219
|
-
### pipe().emitMatch(condition)
|
|
220
|
-
|
|
221
|
-
Observable will send a value to the subscriber only if the return value of the condition matches the data being sent. In
|
|
222
|
-
this case, there is no automatic unsubscription.
|
|
223
|
-
|
|
224
|
-
```ts
|
|
225
|
-
import {Observable} from "evg_observable";
|
|
226
|
-
|
|
227
|
-
const observable$ = new Observable('Some typed data (not only string)');
|
|
228
|
-
const listener1 = (value: string) => console.log('listener1:', value);
|
|
229
|
-
const listener2 = (value: string) => console.log('listener2:', value);
|
|
230
|
-
const TARGET_DATA = 'TARGET_DATA';
|
|
231
|
-
|
|
232
|
-
const subscriber1 = observable$
|
|
233
|
-
.pipe()
|
|
234
|
-
.emitMatch(() => TARGET_DATA)
|
|
235
|
-
.subscribe(listener1);
|
|
236
|
-
const subscriber2 = observable$.subscribe(listener2);
|
|
237
|
-
|
|
238
|
-
console.log(observable$.getValue());
|
|
239
|
-
// Print to console - Some typed data (not only string)
|
|
240
|
-
|
|
241
|
-
observable$.next('Next1 typed data');
|
|
242
|
-
// Print to console - listener2: Next1 typed data
|
|
243
|
-
|
|
244
|
-
observable$.next('Next2 typed data');
|
|
245
|
-
// Print to console - listener2: Next2 typed data
|
|
246
|
-
|
|
247
|
-
observable$.next(TARGET_DATA);
|
|
248
|
-
// Print to console - listener1: TARGET_DATA
|
|
249
|
-
// Print to console - listener2: TARGET_DATA
|
|
250
|
-
|
|
251
|
-
observable$.next('Next4 typed data');
|
|
252
|
-
// Print to console - listener2: Next4 typed data
|
|
253
|
-
|
|
254
|
-
observable$.next(TARGET_DATA);
|
|
255
|
-
// Print to console - listener1: TARGET_DATA
|
|
256
|
-
// Print to console - listener2: TARGET_DATA
|
|
257
|
-
```
|
|
258
|
-
|
|
259
219
|
### pipe().serialize()
|
|
260
220
|
|
|
261
221
|
To convert the observable's data to JSON format, you can use the serialize method. This method turns the observer's
|
|
@@ -501,8 +461,8 @@ women$.pipe()
|
|
|
501
461
|
|
|
502
462
|
// Stream the list of people by applying the age filters
|
|
503
463
|
personal$.pipe()
|
|
504
|
-
.
|
|
505
|
-
.
|
|
464
|
+
.refine(youngAgeFilter)
|
|
465
|
+
.refine(oldAgeFilter)
|
|
506
466
|
.subscribe([men$, women$]);
|
|
507
467
|
|
|
508
468
|
// Stream the list of people considering the hair color
|
|
@@ -614,14 +574,9 @@ observable is set to be a once-off observable to which a listener is subscribed.
|
|
|
614
574
|
| method | will return | description |
|
|
615
575
|
|:-------------------------------------|:---------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
616
576
|
| `.setOnce()` | pipe object | observable will send a value to the subscriber only once, and the subscriber will unsubscribe. |
|
|
617
|
-
| `.unsubscribeByNegative(*condition)` | pipe object | observable will send a value to the subscriber as long as the condition is positive, on the first negative result, the subscriber will unsubscribe |
|
|
618
|
-
| `.unsubscribeByPositive(*condition)` | pipe object | observable will send a value to the subscriber as long as the condition is negative, on the first positive result, the subscriber will unsubscribe |
|
|
619
577
|
| `.unsubscribeBy(*condition)` | pipe object | observable will send a value to the subscriber as long as the condition is negative, on the first positive result, the subscriber will unsubscribe |
|
|
620
|
-
| `.emitByNegative(*condition)` | pipe object | observable will send a value to the listener only if condition returns "false", there is no automatic unsubscription |
|
|
621
|
-
| `.emitByPositive(*condition)` | pipe object | observable will send a value to the listener only if condition returns "true", there is no automatic unsubscription |
|
|
622
578
|
| `.refine(*condition)` | pipe object | observable will send a value to the listener only if condition returns "true", there is no automatic unsubscription |
|
|
623
579
|
| `.pushRefiners(*conditions)` | pipe object | This method allows you to add a group of conditions for filtering data in the pipeline chain. |
|
|
624
|
-
| `.emitMatch(*condition)` | pipe object | observable will send a value to the subscriber only if the return value of the condition matches the data being sent, in this case, there is no automatic unsubscription |
|
|
625
580
|
| `.switch()` | SwitchCase object | transitions the pipe into switch-case mode. In this mode, only the first condition that returns a positive result is triggered, and all others are ignored. This allows you to handle multiple cases more conveniently. |
|
|
626
581
|
| `.case(*condition)` | PipeCase object | Adds a condition to the chain of cases. The entire chain operates on the principle of "OR". This is different from other pipe methods which, when chained, operate on the principle of "AND". |
|
|
627
582
|
| `.pushCases(*conditions)` | PipeCase object | This method allows you to add a group of conditions for filtering cases data in the pipeline chain. |
|
package/package.json
CHANGED
package/repo/evg_observable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const s=(s,
|
|
1
|
+
(()=>{"use strict";const s=(s,i)=>s.order>i.order?1:s.order<i.order?-1:0,i=(s,i)=>s.order>i.order?-1:s.order<i.order?1:0;function e(s,i){const e=s.indexOf(i);return-1!==e&&(s[e]=s[s.length-1],s.length=s.length-1,!0)}function t(s){return"next"in s?i=>s.next(i):s}class r{constructor(s){this.pipe=s,this.counter=s.chain.length?s.chain.length:0}case(s){this.counter++;const i=this.counter,e=this.pipe.chain;return e.push((t=>{t.isAvailable=!0,s(t.payload)&&(t.isBreak=!0),i!==e.length||t.isBreak||(t.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let i=0;i<s.length;i++)this.case(s[i]);return this}}class h{constructor(){this.chain=[],this.flow={isBreak:!1,isUnsubscribe:!1,isAvailable:!1,payload:null}}push(s){return this.chain.push(s),this}setOnce(){return this.push((s=>{this.listener(s.payload),s.isUnsubscribe=!0}))}unsubscribeBy(s){return this.push((i=>{i.isAvailable=!0,s(i.payload)&&(i.isUnsubscribe=!0)}))}refine(s){return this.push((i=>{s(i.payload)&&(i.isAvailable=!0)}))}pushRefiners(s){if(!Array.isArray(s))return this;for(let i=0;i<s.length;i++)this.refine(s[i]);return this}switch(){return new l(this)}then(s){return this.push((i=>{i.payload=s(i.payload),i.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 i=this.chain,e=this.flow;for(let s=0;s<i.length;s++){if(e.isUnsubscribe=!1,e.isAvailable=!1,i[s](e),e.isUnsubscribe)return this.unsubscribe();if(!e.isAvailable)return;if(e.isBreak)break}return s(e.payload)}}class l extends r{subscribe(s,i){return this.pipe.subscribe(s,i)}}class n extends h{constructor(s,i){super(),this.errorHandler=(s,i)=>{console.log(`(Unit of SubscribeObject).send(${s}) ERROR:`,i)},this._order=0,this.isPaused=!1,this.isPipe=!1,this.observable=s,this.isPipe=!!i}subscribe(s,i){return this.listener=function(s){if(Array.isArray(s)){const i=[];for(let e=0;e<s.length;e++)i.push(t(s[e]));return s=>{for(let e=0;e<i.length;e++)i[e](s)}}return t(s)}(s),i&&(this.errorHandler=i),this}unsubscribe(){this.observable&&(this.observable.unSubscribe(this),this.observable=null,this.listener=null,this.chain.length=0)}send(s){try{this.flow.payload=s,this.flow.isBreak=!1,this.processValue(s)}catch(i){this.errorHandler(s,i)}}resume(){this.isPaused=!1}pause(){this.isPaused=!0}get order(){return this._order}set order(s){this._order=s}processValue(s){const i=this.listener;return i?this.observable&&!this.isPaused?this.isPipe?this.processChain(i):i(s):void 0:this.unsubscribe()}}class a{constructor(){this.chain=[],this.flow={isBreak:!1,isAvailable:!1,payload:null},this.response={isOK:!1,payload:void 0}}get isEmpty(){return!this.chain.length}push(s){return this.chain.push(s),this}filter(s){return this.push((i=>{s(i.payload)&&(i.isAvailable=!0)}))}pushFilters(s){if(!Array.isArray(s))return this;for(let i=0;i<s.length;i++)this.filter(s[i]);return this}switch(){return new o(this)}processChain(s){const i=this.chain,e=this.flow,t=this.response;t.isOK=!1,t.payload=void 0,e.payload=s,e.isBreak=!1;try{for(let s=0;s<i.length;s++){if(e.isAvailable=!1,i[s](e),!e.isAvailable)return t;if(e.isBreak)break}}catch(s){return this.errHandler?this.errHandler(s,"Filter.processChain ERROR:"):console.log("Filter.processChain ERROR:",s),t}return t.isOK=!0,t.payload=e.payload,t}addErrorHandler(s){this.errHandler=s}}class o extends r{}class u{constructor(s){this.value=s,this.listeners=[],this.isStop=!0,this.isKilled=!1,this.isProcess=!1,this.trash=[],this.filters=new a}addFilter(s){return s&&this.filters.addErrorHandler(s),this.filters}disable(){this.isStop=!1}enable(){this.isStop=!0}get isEnable(){return this.isStop}next(s){if(!this.isKilled&&this.isStop&&(this.filters.isEmpty||this.filters.processChain(s).isOK)){this.isProcess=!0,this.value=s;for(let i=0;i<this.listeners.length;i++)this.listeners[i].send(s);this.isProcess=!1,this.trash.length&&this.handleListenersForUnsubscribe()}}stream(s){if(!this.isKilled&&this.isStop)for(let i=0;i<s.length;i++)this.next(s[i])}handleListenersForUnsubscribe(){const s=this.trash.length;for(let i=0;i<s;i++)this.unSubscribe(this.trash[i]);this.trash.length=0}unSubscribe(s){this.isKilled||(this.isProcess&&s?this.trash.push(s):this.listeners&&e(this.listeners,s))}destroy(){this.value=null,this.unsubscribeAll(),this.listeners=null,this.isKilled=!0}unsubscribeAll(){this.isKilled||(this.listeners.length=0)}getValue(){if(!this.isKilled)return this.value}size(){return this.isKilled?0:this.listeners.length}subscribe(s,i){if(!this.isListener(s))return;const e=new n(this,!1);return this.addObserver(e,s,i),e}addObserver(s,i,e){s.subscribe(i,e),this.listeners.push(s)}isListener(s){return!this.isKilled&&!!s}pipe(){if(this.isKilled)return;const s=new n(this,!0);return this.listeners.push(s),s}get isDestroyed(){return this.isKilled}}class c extends n{constructor(s,i){super(s,i)}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,i){return super.subscribe(s,i),this}setOnce(){return super.setOnce()}}const d=window;d.Observable=u,d.Collector=class{constructor(){this.list=[],this.isKilled=!1}collect(...s){this.isKilled||this.list.push(...s)}unsubscribe(s){this.isKilled||(s?.unsubscribe(),e(this.list,s))}unsubscribeAll(){if(!this.isKilled)for(;this.list.length>0;)this.unsubscribe(this.list.pop())}size(){return this.isKilled?0:this.list.length}destroy(){this.unsubscribeAll(),this.list.length=0,this.list=0,this.isKilled=!0}get isDestroyed(){return this.isKilled}},d.OrderedObservable=class extends u{constructor(){super(...arguments),this.sortDirection=s}setAscendingSort(){return this.sortDirection=s,this.sortByOrder()}setDescendingSort(){return this.sortDirection=i,this.sortByOrder()}sortByOrder(){return!this.isKilled&&(this.listeners.sort(this.sortDirection),!0)}subscribe(s,i){if(!this.isListener(s))return;const e=new c(this,!1);return this.addObserver(e,s,i),e}pipe(){if(this.isKilled)return;const s=new c(this,!0);return this.listeners.push(s),s}unSubscribe(s){this.isKilled||(this.isProcess&&s?this.trash.push(s):this.listeners&&function(s,i){const e=s.indexOf(i);-1!==e&&s.splice(e,1)}(this.listeners,s))}}})();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICallback, IChainContainer } from "./Types";
|
|
2
|
+
export declare abstract class SwitchCase<T, P extends IChainContainer, W> {
|
|
3
|
+
protected pipe: P;
|
|
4
|
+
protected counter: number;
|
|
5
|
+
constructor(pipe: P);
|
|
6
|
+
case(condition: ICallback<any>): W;
|
|
7
|
+
pushCases(conditions: ICallback<any>[]): W;
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwitchCase = void 0;
|
|
4
|
+
class SwitchCase {
|
|
5
|
+
pipe;
|
|
6
|
+
counter;
|
|
7
|
+
constructor(pipe) {
|
|
8
|
+
this.pipe = pipe;
|
|
9
|
+
this.counter = pipe.chain.length ? pipe.chain.length : 0;
|
|
10
|
+
}
|
|
11
|
+
case(condition) {
|
|
12
|
+
this.counter++;
|
|
13
|
+
const id = this.counter;
|
|
14
|
+
const chain = this.pipe.chain;
|
|
15
|
+
chain.push((data) => {
|
|
16
|
+
data.isAvailable = true;
|
|
17
|
+
if (condition(data.payload))
|
|
18
|
+
data.isBreak = true;
|
|
19
|
+
if (id === chain.length && !data.isBreak)
|
|
20
|
+
data.isAvailable = false;
|
|
21
|
+
});
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
pushCases(conditions) {
|
|
25
|
+
if (!Array.isArray(conditions))
|
|
26
|
+
return this;
|
|
27
|
+
for (let i = 0; i < conditions.length; i++)
|
|
28
|
+
this.case(conditions[i]);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.SwitchCase = SwitchCase;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ICollector, ISubscriptionLike } from "./Types";
|
|
2
2
|
export declare class Collector implements ICollector {
|
|
3
3
|
protected list: ISubscriptionLike[];
|
|
4
|
-
private
|
|
4
|
+
private isKilled;
|
|
5
5
|
collect(...subscriptionLikeList: ISubscriptionLike[]): void;
|
|
6
6
|
unsubscribe(subscriptionLike: ISubscriptionLike | undefined): void;
|
|
7
7
|
unsubscribeAll(): void | null;
|
package/src/outLib/Collector.js
CHANGED
|
@@ -4,25 +4,25 @@ exports.Collector = void 0;
|
|
|
4
4
|
const FunctionLibs_1 = require("./FunctionLibs");
|
|
5
5
|
class Collector {
|
|
6
6
|
list = [];
|
|
7
|
-
|
|
7
|
+
isKilled = false;
|
|
8
8
|
collect(...subscriptionLikeList) {
|
|
9
|
-
if (!this.
|
|
9
|
+
if (!this.isKilled)
|
|
10
10
|
this.list.push(...subscriptionLikeList);
|
|
11
11
|
}
|
|
12
12
|
unsubscribe(subscriptionLike) {
|
|
13
|
-
if (this.
|
|
13
|
+
if (this.isKilled)
|
|
14
14
|
return;
|
|
15
15
|
subscriptionLike?.unsubscribe();
|
|
16
16
|
(0, FunctionLibs_1.quickDeleteFromArray)(this.list, subscriptionLike);
|
|
17
17
|
}
|
|
18
18
|
unsubscribeAll() {
|
|
19
|
-
if (this.
|
|
19
|
+
if (this.isKilled)
|
|
20
20
|
return;
|
|
21
21
|
while (this.list.length > 0)
|
|
22
22
|
this.unsubscribe(this.list.pop());
|
|
23
23
|
}
|
|
24
24
|
size() {
|
|
25
|
-
if (this.
|
|
25
|
+
if (this.isKilled)
|
|
26
26
|
return 0;
|
|
27
27
|
return this.list.length;
|
|
28
28
|
}
|
|
@@ -30,10 +30,10 @@ class Collector {
|
|
|
30
30
|
this.unsubscribeAll();
|
|
31
31
|
this.list.length = 0;
|
|
32
32
|
this.list = 0;
|
|
33
|
-
this.
|
|
33
|
+
this.isKilled = true;
|
|
34
34
|
}
|
|
35
35
|
get isDestroyed() {
|
|
36
|
-
return this.
|
|
36
|
+
return this.isKilled;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.Collector = Collector;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ICallback, IErrorCallback, IFilter,
|
|
1
|
+
import { ICallback, IErrorCallback, IFilter, IFilterChainCallback, IFilterPayload, IFilterResponse, IFilterSetup, IFilterSwitch } from "./Types";
|
|
2
|
+
import { SwitchCase } from "./AbstractSwitchCase";
|
|
2
3
|
export declare class FilterCollection<T> implements IFilter<T>, IFilterSwitch<T> {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
chain: IFilterChainCallback[];
|
|
5
|
+
flow: IFilterPayload;
|
|
5
6
|
response: IFilterResponse;
|
|
6
|
-
private
|
|
7
|
+
private errHandler;
|
|
7
8
|
get isEmpty(): boolean;
|
|
8
9
|
private push;
|
|
9
10
|
filter(condition: ICallback<any>): IFilterSetup<T>;
|
|
@@ -12,10 +13,5 @@ export declare class FilterCollection<T> implements IFilter<T>, IFilterSwitch<T>
|
|
|
12
13
|
processChain(value: T): IFilterResponse;
|
|
13
14
|
addErrorHandler(errorHandler: IErrorCallback): void;
|
|
14
15
|
}
|
|
15
|
-
export declare class FilterSwitchCase<T>
|
|
16
|
-
private pipe;
|
|
17
|
-
private caseCounter;
|
|
18
|
-
constructor(pipe: FilterCollection<T>);
|
|
19
|
-
case(condition: ICallback<any>): IFilterCase<T>;
|
|
20
|
-
pushCases(conditions: ICallback<any>[]): IFilterCase<T>;
|
|
16
|
+
export declare class FilterSwitchCase<T> extends SwitchCase<T, FilterCollection<T>, IFilter<T>> {
|
|
21
17
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterSwitchCase = exports.FilterCollection = void 0;
|
|
4
|
+
const AbstractSwitchCase_1 = require("./AbstractSwitchCase");
|
|
4
5
|
class FilterCollection {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
chain = [];
|
|
7
|
+
flow = { isBreak: false, isAvailable: false, payload: null };
|
|
7
8
|
response = { isOK: false, payload: undefined };
|
|
8
|
-
|
|
9
|
+
errHandler;
|
|
9
10
|
get isEmpty() {
|
|
10
|
-
return !this.
|
|
11
|
+
return !this.chain.length;
|
|
11
12
|
}
|
|
12
13
|
push(callback) {
|
|
13
|
-
this.
|
|
14
|
+
this.chain.push(callback);
|
|
14
15
|
return this;
|
|
15
16
|
}
|
|
16
17
|
filter(condition) {
|
|
@@ -30,26 +31,26 @@ class FilterCollection {
|
|
|
30
31
|
return new FilterSwitchCase(this);
|
|
31
32
|
}
|
|
32
33
|
processChain(value) {
|
|
33
|
-
const chain = this.
|
|
34
|
-
const data = this.
|
|
34
|
+
const chain = this.chain;
|
|
35
|
+
const data = this.flow;
|
|
35
36
|
const response = this.response;
|
|
36
37
|
response.isOK = false;
|
|
37
38
|
response.payload = undefined;
|
|
38
39
|
data.payload = value;
|
|
39
|
-
data.
|
|
40
|
+
data.isBreak = false;
|
|
40
41
|
try {
|
|
41
42
|
for (let i = 0; i < chain.length; i++) {
|
|
42
43
|
data.isAvailable = false;
|
|
43
44
|
chain[i](data);
|
|
44
45
|
if (!data.isAvailable)
|
|
45
46
|
return response;
|
|
46
|
-
if (data.
|
|
47
|
+
if (data.isBreak)
|
|
47
48
|
break;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
catch (err) {
|
|
51
|
-
if (this.
|
|
52
|
-
this.
|
|
52
|
+
if (this.errHandler) {
|
|
53
|
+
this.errHandler(err, "Filter.processChain ERROR:");
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
56
|
console.log("Filter.processChain ERROR:", err);
|
|
@@ -61,36 +62,10 @@ class FilterCollection {
|
|
|
61
62
|
return response;
|
|
62
63
|
}
|
|
63
64
|
addErrorHandler(errorHandler) {
|
|
64
|
-
this.
|
|
65
|
+
this.errHandler = errorHandler;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
exports.FilterCollection = FilterCollection;
|
|
68
|
-
class FilterSwitchCase {
|
|
69
|
-
pipe;
|
|
70
|
-
caseCounter;
|
|
71
|
-
constructor(pipe) {
|
|
72
|
-
this.pipe = pipe;
|
|
73
|
-
this.caseCounter = pipe.chainHandlers.length ? pipe.chainHandlers.length : 0;
|
|
74
|
-
}
|
|
75
|
-
case(condition) {
|
|
76
|
-
this.caseCounter++;
|
|
77
|
-
const id = this.caseCounter;
|
|
78
|
-
const chain = this.pipe.chainHandlers;
|
|
79
|
-
chain.push((data) => {
|
|
80
|
-
data.isAvailable = true;
|
|
81
|
-
if (condition(data.payload))
|
|
82
|
-
data.isBreakChain = true;
|
|
83
|
-
if (id === chain.length && !data.isBreakChain)
|
|
84
|
-
data.isAvailable = false;
|
|
85
|
-
});
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
pushCases(conditions) {
|
|
89
|
-
if (!Array.isArray(conditions))
|
|
90
|
-
return this;
|
|
91
|
-
for (let i = 0; i < conditions.length; i++)
|
|
92
|
-
this.case(conditions[i]);
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
69
|
+
class FilterSwitchCase extends AbstractSwitchCase_1.SwitchCase {
|
|
95
70
|
}
|
|
96
71
|
exports.FilterSwitchCase = FilterSwitchCase;
|
|
@@ -3,11 +3,11 @@ 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 listeners: ISubscribeObject<T>[];
|
|
6
|
-
private
|
|
7
|
-
protected
|
|
8
|
-
protected
|
|
9
|
-
protected
|
|
10
|
-
private
|
|
6
|
+
private isStop;
|
|
7
|
+
protected isKilled: boolean;
|
|
8
|
+
protected isProcess: boolean;
|
|
9
|
+
protected trash: ISubscriptionLike[];
|
|
10
|
+
private filters;
|
|
11
11
|
constructor(value: T);
|
|
12
12
|
addFilter(errorHandler?: IErrorCallback): IFilterSetup<T>;
|
|
13
13
|
disable(): void;
|
|
@@ -23,7 +23,7 @@ export declare class Observable<T> implements IObserver<T>, IStream<T>, IAddFilt
|
|
|
23
23
|
size(): number;
|
|
24
24
|
subscribe(observer: ISubscribeGroup<T>, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
25
25
|
protected addObserver(subscribeObject: SubscribeObject<T>, observer: ISubscribeGroup<T>, errorHandler?: IErrorCallback): void;
|
|
26
|
-
protected
|
|
26
|
+
protected isListener(listener: ISubscribeGroup<T>): boolean;
|
|
27
27
|
pipe(): ISetup<T> | undefined;
|
|
28
28
|
get isDestroyed(): boolean;
|
|
29
29
|
}
|
package/src/outLib/Observable.js
CHANGED
|
@@ -7,64 +7,64 @@ const FilterCollection_1 = require("./FilterCollection");
|
|
|
7
7
|
class Observable {
|
|
8
8
|
value;
|
|
9
9
|
listeners = [];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
isStop = true;
|
|
11
|
+
isKilled = false;
|
|
12
|
+
isProcess = false;
|
|
13
|
+
trash = [];
|
|
14
|
+
filters = new FilterCollection_1.FilterCollection();
|
|
15
15
|
constructor(value) {
|
|
16
16
|
this.value = value;
|
|
17
17
|
}
|
|
18
18
|
addFilter(errorHandler) {
|
|
19
19
|
if (errorHandler) {
|
|
20
|
-
this.
|
|
20
|
+
this.filters.addErrorHandler(errorHandler);
|
|
21
21
|
}
|
|
22
|
-
return this.
|
|
22
|
+
return this.filters;
|
|
23
23
|
}
|
|
24
24
|
disable() {
|
|
25
|
-
this.
|
|
25
|
+
this.isStop = false;
|
|
26
26
|
}
|
|
27
27
|
enable() {
|
|
28
|
-
this.
|
|
28
|
+
this.isStop = true;
|
|
29
29
|
}
|
|
30
30
|
get isEnable() {
|
|
31
|
-
return this.
|
|
31
|
+
return this.isStop;
|
|
32
32
|
}
|
|
33
33
|
next(value) {
|
|
34
|
-
if (this.
|
|
34
|
+
if (this.isKilled)
|
|
35
35
|
return;
|
|
36
|
-
if (!this.
|
|
36
|
+
if (!this.isStop)
|
|
37
37
|
return;
|
|
38
|
-
if (!this.
|
|
39
|
-
if (!this.
|
|
38
|
+
if (!this.filters.isEmpty) {
|
|
39
|
+
if (!this.filters.processChain(value).isOK)
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
this.
|
|
42
|
+
this.isProcess = true;
|
|
43
43
|
this.value = value;
|
|
44
44
|
for (let i = 0; i < this.listeners.length; i++)
|
|
45
45
|
this.listeners[i].send(value);
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
46
|
+
this.isProcess = false;
|
|
47
|
+
this.trash.length && this.handleListenersForUnsubscribe();
|
|
48
48
|
}
|
|
49
49
|
stream(values) {
|
|
50
|
-
if (this.
|
|
50
|
+
if (this.isKilled)
|
|
51
51
|
return;
|
|
52
|
-
if (!this.
|
|
52
|
+
if (!this.isStop)
|
|
53
53
|
return;
|
|
54
54
|
for (let i = 0; i < values.length; i++)
|
|
55
55
|
this.next(values[i]);
|
|
56
56
|
}
|
|
57
57
|
handleListenersForUnsubscribe() {
|
|
58
|
-
const length = this.
|
|
58
|
+
const length = this.trash.length;
|
|
59
59
|
for (let i = 0; i < length; i++)
|
|
60
|
-
this.unSubscribe(this.
|
|
61
|
-
this.
|
|
60
|
+
this.unSubscribe(this.trash[i]);
|
|
61
|
+
this.trash.length = 0;
|
|
62
62
|
}
|
|
63
63
|
unSubscribe(listener) {
|
|
64
|
-
if (this.
|
|
64
|
+
if (this.isKilled)
|
|
65
65
|
return;
|
|
66
|
-
if (this.
|
|
67
|
-
this.
|
|
66
|
+
if (this.isProcess && listener) {
|
|
67
|
+
this.trash.push(listener);
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
this.listeners && !(0, FunctionLibs_1.quickDeleteFromArray)(this.listeners, listener);
|
|
@@ -73,25 +73,25 @@ class Observable {
|
|
|
73
73
|
this.value = null;
|
|
74
74
|
this.unsubscribeAll();
|
|
75
75
|
this.listeners = null;
|
|
76
|
-
this.
|
|
76
|
+
this.isKilled = true;
|
|
77
77
|
}
|
|
78
78
|
unsubscribeAll() {
|
|
79
|
-
if (this.
|
|
79
|
+
if (this.isKilled)
|
|
80
80
|
return;
|
|
81
81
|
this.listeners.length = 0;
|
|
82
82
|
}
|
|
83
83
|
getValue() {
|
|
84
|
-
if (this.
|
|
84
|
+
if (this.isKilled)
|
|
85
85
|
return undefined;
|
|
86
86
|
return this.value;
|
|
87
87
|
}
|
|
88
88
|
size() {
|
|
89
|
-
if (this.
|
|
89
|
+
if (this.isKilled)
|
|
90
90
|
return 0;
|
|
91
91
|
return this.listeners.length;
|
|
92
92
|
}
|
|
93
93
|
subscribe(observer, errorHandler) {
|
|
94
|
-
if (!this.
|
|
94
|
+
if (!this.isListener(observer))
|
|
95
95
|
return undefined;
|
|
96
96
|
const subscribeObject = new SubscribeObject_1.SubscribeObject(this, false);
|
|
97
97
|
this.addObserver(subscribeObject, observer, errorHandler);
|
|
@@ -101,20 +101,20 @@ class Observable {
|
|
|
101
101
|
subscribeObject.subscribe(observer, errorHandler);
|
|
102
102
|
this.listeners.push(subscribeObject);
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
if (this.
|
|
104
|
+
isListener(listener) {
|
|
105
|
+
if (this.isKilled)
|
|
106
106
|
return false;
|
|
107
107
|
return !!listener;
|
|
108
108
|
}
|
|
109
109
|
pipe() {
|
|
110
|
-
if (this.
|
|
110
|
+
if (this.isKilled)
|
|
111
111
|
return undefined;
|
|
112
112
|
const subscribeObject = new SubscribeObject_1.SubscribeObject(this, true);
|
|
113
113
|
this.listeners.push(subscribeObject);
|
|
114
114
|
return subscribeObject;
|
|
115
115
|
}
|
|
116
116
|
get isDestroyed() {
|
|
117
|
-
return this.
|
|
117
|
+
return this.isKilled;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
exports.Observable = Observable;
|
|
@@ -15,30 +15,30 @@ class OrderedObservable extends Observable_1.Observable {
|
|
|
15
15
|
return this.sortByOrder();
|
|
16
16
|
}
|
|
17
17
|
sortByOrder() {
|
|
18
|
-
if (this.
|
|
18
|
+
if (this.isKilled)
|
|
19
19
|
return false;
|
|
20
20
|
this.listeners.sort(this.sortDirection);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
subscribe(listener, errorHandler) {
|
|
24
|
-
if (!this.
|
|
24
|
+
if (!this.isListener(listener))
|
|
25
25
|
return undefined;
|
|
26
26
|
const subscribeObject = new OrderedSubscribeObject_1.OrderedSubscribeObject(this, false);
|
|
27
27
|
this.addObserver(subscribeObject, listener, errorHandler);
|
|
28
28
|
return subscribeObject;
|
|
29
29
|
}
|
|
30
30
|
pipe() {
|
|
31
|
-
if (this.
|
|
31
|
+
if (this.isKilled)
|
|
32
32
|
return undefined;
|
|
33
33
|
const subscribeObject = new OrderedSubscribeObject_1.OrderedSubscribeObject(this, true);
|
|
34
34
|
this.listeners.push(subscribeObject);
|
|
35
35
|
return subscribeObject;
|
|
36
36
|
}
|
|
37
37
|
unSubscribe(listener) {
|
|
38
|
-
if (this.
|
|
38
|
+
if (this.isKilled)
|
|
39
39
|
return;
|
|
40
|
-
if (this.
|
|
41
|
-
this.
|
|
40
|
+
if (this.isProcess && listener) {
|
|
41
|
+
this.trash.push(listener);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
this.listeners && !(0, FunctionLibs_1.deleteFromArray)(this.listeners, listener);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SubscribeObject } from "./SubscribeObject";
|
|
2
|
-
import {
|
|
2
|
+
import { IErrorCallback, IListener, IOrdered, IOrderedSetup, IOrderedSubscribe, IOrderedSubscriptionLike, ISetObservableValue } from "./Types";
|
|
3
3
|
import { OrderedObservable } from "./OrderedObservable";
|
|
4
4
|
export declare class OrderedSubscribeObject<T> extends SubscribeObject<T> implements IOrderedSetup<T> {
|
|
5
5
|
constructor(observable: OrderedObservable<T> | IOrdered<T>, isPipe?: boolean);
|
|
@@ -7,9 +7,4 @@ export declare class OrderedSubscribeObject<T> extends SubscribeObject<T> implem
|
|
|
7
7
|
set order(value: number);
|
|
8
8
|
subscribe(observer: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): IOrderedSubscriptionLike;
|
|
9
9
|
setOnce(): IOrderedSubscribe<T>;
|
|
10
|
-
unsubscribeByNegative(condition: ICallback<any>): IOrderedSetup<T>;
|
|
11
|
-
unsubscribeByPositive(condition: ICallback<any>): IOrderedSetup<T>;
|
|
12
|
-
emitByNegative(condition: ICallback<any>): IOrderedSetup<T>;
|
|
13
|
-
emitByPositive(condition: ICallback<any>): IOrderedSetup<T>;
|
|
14
|
-
emitMatch(condition: ICallback<any>): IOrderedSetup<T>;
|
|
15
10
|
}
|
|
@@ -25,20 +25,5 @@ class OrderedSubscribeObject extends SubscribeObject_1.SubscribeObject {
|
|
|
25
25
|
setOnce() {
|
|
26
26
|
return super.setOnce();
|
|
27
27
|
}
|
|
28
|
-
unsubscribeByNegative(condition) {
|
|
29
|
-
return super.unsubscribeByNegative(condition);
|
|
30
|
-
}
|
|
31
|
-
unsubscribeByPositive(condition) {
|
|
32
|
-
return super.unsubscribeByPositive(condition);
|
|
33
|
-
}
|
|
34
|
-
emitByNegative(condition) {
|
|
35
|
-
return super.emitByNegative(condition);
|
|
36
|
-
}
|
|
37
|
-
emitByPositive(condition) {
|
|
38
|
-
return super.emitByPositive(condition);
|
|
39
|
-
}
|
|
40
|
-
emitMatch(condition) {
|
|
41
|
-
return super.emitMatch(condition);
|
|
42
|
-
}
|
|
43
28
|
}
|
|
44
29
|
exports.OrderedSubscribeObject = OrderedSubscribeObject;
|
package/src/outLib/Pipe.d.ts
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
import { ICallback, IChainCallback, IErrorCallback, IListener, IPipeCase, IPipePayload, ISetObservableValue, ISetup, ISubscribe, ISubscriptionLike } from "./Types";
|
|
2
|
+
import { SwitchCase } from "./AbstractSwitchCase";
|
|
2
3
|
export declare abstract class Pipe<T> implements ISubscribe<T> {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
chain: IChainCallback[];
|
|
5
|
+
flow: IPipePayload;
|
|
5
6
|
abstract subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
6
7
|
private push;
|
|
7
8
|
setOnce(): ISubscribe<T>;
|
|
8
|
-
unsubscribeByNegative(condition: ICallback<T>): ISetup<T>;
|
|
9
|
-
unsubscribeByPositive(condition: ICallback<T>): ISetup<T>;
|
|
10
9
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
11
|
-
emitByNegative(condition: ICallback<T>): ISetup<T>;
|
|
12
|
-
emitByPositive(condition: ICallback<T>): ISetup<T>;
|
|
13
10
|
refine(condition: ICallback<T>): ISetup<T>;
|
|
14
11
|
pushRefiners(conditions: ICallback<any>[]): ISetup<T>;
|
|
15
|
-
|
|
16
|
-
switch(): SwitchCase<T>;
|
|
12
|
+
switch(): PipeSwitchCase<T>;
|
|
17
13
|
then<K>(condition: ICallback<T>): ISetup<K>;
|
|
18
14
|
serialize(): ISetup<string>;
|
|
19
15
|
deserialize<K>(): ISetup<K>;
|
|
20
16
|
processChain(listener: IListener<T>): void;
|
|
21
17
|
}
|
|
22
|
-
export declare class
|
|
23
|
-
private pipe;
|
|
24
|
-
private caseCounter;
|
|
25
|
-
constructor(pipe: Pipe<T>);
|
|
18
|
+
export declare class PipeSwitchCase<T> extends SwitchCase<T, Pipe<T>, IPipeCase<T>> implements ISubscribe<T> {
|
|
26
19
|
subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
27
|
-
case(condition: ICallback<any>): IPipeCase<T> & ISubscribe<T>;
|
|
28
|
-
pushCases(conditions: ICallback<any>[]): IPipeCase<T> & ISubscribe<T>;
|
|
29
20
|
}
|
package/src/outLib/Pipe.js
CHANGED
|
@@ -1,66 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PipeSwitchCase = exports.Pipe = void 0;
|
|
4
|
+
const AbstractSwitchCase_1 = require("./AbstractSwitchCase");
|
|
4
5
|
class Pipe {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
chain = [];
|
|
7
|
+
flow = { isBreak: false, isUnsubscribe: false, isAvailable: false, payload: null };
|
|
7
8
|
push(callback) {
|
|
8
|
-
this.
|
|
9
|
+
this.chain.push(callback);
|
|
9
10
|
return this;
|
|
10
11
|
}
|
|
11
12
|
setOnce() {
|
|
12
13
|
return this.push((data) => {
|
|
13
14
|
this.listener(data.payload);
|
|
14
|
-
data.
|
|
15
|
+
data.isUnsubscribe = true;
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
return this.push((data) => {
|
|
19
|
-
data.isAvailable = true;
|
|
20
|
-
if (!condition(data.payload))
|
|
21
|
-
data.isNeedUnsubscribe = true;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
unsubscribeByPositive(condition) {
|
|
18
|
+
unsubscribeBy(condition) {
|
|
25
19
|
return this.push((data) => {
|
|
26
20
|
data.isAvailable = true;
|
|
27
21
|
if (condition(data.payload))
|
|
28
|
-
data.
|
|
22
|
+
data.isUnsubscribe = true;
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
return this.unsubscribeByPositive(condition);
|
|
33
|
-
}
|
|
34
|
-
emitByNegative(condition) {
|
|
35
|
-
return this.push((data) => {
|
|
36
|
-
if (!condition(data.payload))
|
|
37
|
-
data.isAvailable = true;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
emitByPositive(condition) {
|
|
25
|
+
refine(condition) {
|
|
41
26
|
return this.push((data) => {
|
|
42
27
|
if (condition(data.payload))
|
|
43
28
|
data.isAvailable = true;
|
|
44
29
|
});
|
|
45
30
|
}
|
|
46
|
-
refine(condition) {
|
|
47
|
-
return this.emitByPositive(condition);
|
|
48
|
-
}
|
|
49
31
|
pushRefiners(conditions) {
|
|
50
32
|
if (!Array.isArray(conditions))
|
|
51
33
|
return this;
|
|
52
34
|
for (let i = 0; i < conditions.length; i++)
|
|
53
|
-
this.
|
|
35
|
+
this.refine(conditions[i]);
|
|
54
36
|
return this;
|
|
55
37
|
}
|
|
56
|
-
emitMatch(condition) {
|
|
57
|
-
return this.push((data) => {
|
|
58
|
-
if (condition(data.payload) == data.payload)
|
|
59
|
-
data.isAvailable = true;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
38
|
switch() {
|
|
63
|
-
return new
|
|
39
|
+
return new PipeSwitchCase(this);
|
|
64
40
|
}
|
|
65
41
|
then(condition) {
|
|
66
42
|
return this.push((data) => {
|
|
@@ -81,52 +57,26 @@ class Pipe {
|
|
|
81
57
|
});
|
|
82
58
|
}
|
|
83
59
|
processChain(listener) {
|
|
84
|
-
const chain = this.
|
|
85
|
-
const data = this.
|
|
60
|
+
const chain = this.chain;
|
|
61
|
+
const data = this.flow;
|
|
86
62
|
for (let i = 0; i < chain.length; i++) {
|
|
87
|
-
data.
|
|
63
|
+
data.isUnsubscribe = false;
|
|
88
64
|
data.isAvailable = false;
|
|
89
65
|
chain[i](data);
|
|
90
|
-
if (data.
|
|
66
|
+
if (data.isUnsubscribe)
|
|
91
67
|
return this.unsubscribe();
|
|
92
68
|
if (!data.isAvailable)
|
|
93
69
|
return;
|
|
94
|
-
if (data.
|
|
70
|
+
if (data.isBreak)
|
|
95
71
|
break;
|
|
96
72
|
}
|
|
97
73
|
return listener(data.payload);
|
|
98
74
|
}
|
|
99
75
|
}
|
|
100
76
|
exports.Pipe = Pipe;
|
|
101
|
-
class SwitchCase {
|
|
102
|
-
pipe;
|
|
103
|
-
caseCounter;
|
|
104
|
-
constructor(pipe) {
|
|
105
|
-
this.pipe = pipe;
|
|
106
|
-
this.caseCounter = pipe.chainHandlers.length ? pipe.chainHandlers.length : 0;
|
|
107
|
-
}
|
|
77
|
+
class PipeSwitchCase extends AbstractSwitchCase_1.SwitchCase {
|
|
108
78
|
subscribe(listener, errorHandler) {
|
|
109
79
|
return this.pipe.subscribe(listener, errorHandler);
|
|
110
80
|
}
|
|
111
|
-
case(condition) {
|
|
112
|
-
this.caseCounter++;
|
|
113
|
-
const id = this.caseCounter;
|
|
114
|
-
const chain = this.pipe.chainHandlers;
|
|
115
|
-
chain.push((data) => {
|
|
116
|
-
data.isAvailable = true;
|
|
117
|
-
if (condition(data.payload))
|
|
118
|
-
data.isBreakChain = true;
|
|
119
|
-
if (id === chain.length && !data.isBreakChain)
|
|
120
|
-
data.isAvailable = false;
|
|
121
|
-
});
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
pushCases(conditions) {
|
|
125
|
-
if (!Array.isArray(conditions))
|
|
126
|
-
return this;
|
|
127
|
-
for (let i = 0; i < conditions.length; i++)
|
|
128
|
-
this.case(conditions[i]);
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
81
|
}
|
|
132
|
-
exports.
|
|
82
|
+
exports.PipeSwitchCase = PipeSwitchCase;
|
|
@@ -28,12 +28,12 @@ class SubscribeObject extends Pipe_1.Pipe {
|
|
|
28
28
|
this.observable.unSubscribe(this);
|
|
29
29
|
this.observable = null;
|
|
30
30
|
this.listener = null;
|
|
31
|
-
this.
|
|
31
|
+
this.chain.length = 0;
|
|
32
32
|
}
|
|
33
33
|
send(value) {
|
|
34
34
|
try {
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
35
|
+
this.flow.payload = value;
|
|
36
|
+
this.flow.isBreak = false;
|
|
37
37
|
this.processValue(value);
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
package/src/outLib/Types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PipeSwitchCase } from "./Pipe";
|
|
2
2
|
import { FilterSwitchCase } from "./FilterCollection";
|
|
3
3
|
export type ICallback<T> = (value?: T) => any;
|
|
4
4
|
export type IErrorCallback = (errorData: any, errorMessage: any) => void;
|
|
@@ -14,10 +14,10 @@ export type IOrder = {
|
|
|
14
14
|
order: number;
|
|
15
15
|
};
|
|
16
16
|
export type ISwitch<T> = {
|
|
17
|
-
switch():
|
|
17
|
+
switch(): PipeSwitchCase<T>;
|
|
18
18
|
};
|
|
19
19
|
export type IOrderedSwitch<T> = {
|
|
20
|
-
switch():
|
|
20
|
+
switch(): PipeSwitchCase<T>;
|
|
21
21
|
};
|
|
22
22
|
export type IOnce<T> = {
|
|
23
23
|
setOnce(): ISubscribe<T>;
|
|
@@ -31,8 +31,8 @@ export type ISetObservableValue = {
|
|
|
31
31
|
export type ISubscriptionLike = {
|
|
32
32
|
unsubscribe(): void;
|
|
33
33
|
};
|
|
34
|
-
export type ISetup<T> =
|
|
35
|
-
export type IOrderedSetup<T> =
|
|
34
|
+
export type ISetup<T> = IUnsubscribeByPositive<T> & IEmitByPositive<T> & IOnce<T> & ISwitch<T> & ITransform<T> & ISerialisation & ISubscribe<T>;
|
|
35
|
+
export type IOrderedSetup<T> = IOrderedUnsubscribeByPositive<T> & IOrderedEmitByPositive<T> & IOrderedOnce<T> & IOrderedSwitch<T> & IOrderedTransform<T> & IOrderedSerialisation & IOrderedSubscribe<T>;
|
|
36
36
|
export type ISubscribeObject<T> = ISubscriptionLike & IPause & IOrder & ISend<T> & ISetup<T>;
|
|
37
37
|
export type ISubscribeCounter = {
|
|
38
38
|
size(): number;
|
|
@@ -70,11 +70,9 @@ export type IOrderedUnsubscribeByNegative<T> = {
|
|
|
70
70
|
unsubscribeByNegative(condition: ICallback<T>): IOrderedSetup<T>;
|
|
71
71
|
};
|
|
72
72
|
export type IUnsubscribeByPositive<T> = {
|
|
73
|
-
unsubscribeByPositive(condition: ICallback<T>): ISetup<T>;
|
|
74
73
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
75
74
|
};
|
|
76
75
|
export type IOrderedUnsubscribeByPositive<T> = {
|
|
77
|
-
unsubscribeByPositive(condition: ICallback<T>): IOrderedSetup<T>;
|
|
78
76
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
79
77
|
};
|
|
80
78
|
export type IEmitByNegative<T> = {
|
|
@@ -84,7 +82,6 @@ export type IOrderedEmitByNegative<T> = {
|
|
|
84
82
|
emitByNegative(condition: ICallback<T>): IOrderedSetup<T>;
|
|
85
83
|
};
|
|
86
84
|
export type IEmitByPositive<T> = {
|
|
87
|
-
emitByPositive(condition: ICallback<T>): ISetup<T>;
|
|
88
85
|
refine(condition: ICallback<T>): ISetup<T>;
|
|
89
86
|
pushRefiners(conditions: ICallback<T>[]): ISetup<T>;
|
|
90
87
|
};
|
|
@@ -96,7 +93,6 @@ export type ISerialisation = {
|
|
|
96
93
|
deserialize<K>(): ISetup<K>;
|
|
97
94
|
};
|
|
98
95
|
export type IOrderedEmitByPositive<T> = {
|
|
99
|
-
emitByPositive(condition: ICallback<any>): IOrderedSetup<T>;
|
|
100
96
|
refine(condition: ICallback<any>): ISetup<T>;
|
|
101
97
|
pushRefiners(conditions: ICallback<any>[]): ISetup<T>;
|
|
102
98
|
};
|
|
@@ -126,14 +122,17 @@ export type IOrderedSubscriptionLike = (ISubscriptionLike & IOrder);
|
|
|
126
122
|
export type IOrderedSubscribe<T> = {
|
|
127
123
|
subscribe(listener: IListener<T>, errorHandler?: IErrorCallback): IOrderedSubscriptionLike;
|
|
128
124
|
};
|
|
125
|
+
export type IChainContainer = {
|
|
126
|
+
chain: any[];
|
|
127
|
+
};
|
|
129
128
|
export type IPipePayload = {
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
isBreak: boolean;
|
|
130
|
+
isUnsubscribe: boolean;
|
|
132
131
|
isAvailable: boolean;
|
|
133
132
|
payload: any;
|
|
134
133
|
};
|
|
135
134
|
export type IChainCallback = (data: IPipePayload) => void;
|
|
136
|
-
export type IPipeCase<T> = {
|
|
135
|
+
export type IPipeCase<T> = ISubscribe<T> & {
|
|
137
136
|
case(condition: ICallback<any>): IPipeCase<T> & ISubscribe<T>;
|
|
138
137
|
pushCases(conditions: ICallback<any>[]): IPipeCase<T> & ISubscribe<T>;
|
|
139
138
|
};
|
|
@@ -155,7 +154,7 @@ export type IFilterCase<T> = {
|
|
|
155
154
|
pushCases(conditions: ICallback<any>[]): IFilterCase<T>;
|
|
156
155
|
};
|
|
157
156
|
export type IFilterPayload = {
|
|
158
|
-
|
|
157
|
+
isBreak: boolean;
|
|
159
158
|
isAvailable: boolean;
|
|
160
159
|
payload: any;
|
|
161
160
|
};
|