evg_observable 2.15.1 → 2.15.2
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 +1 -1
- package/src/outLib/AbstractSwitchCase.d.ts +0 -29
- package/src/outLib/AbstractSwitchCase.js +0 -29
- package/src/outLib/Collector.d.ts +0 -45
- package/src/outLib/Collector.js +0 -45
- package/src/outLib/FilterCollection.d.ts +0 -53
- package/src/outLib/FilterCollection.js +0 -53
- package/src/outLib/FunctionLibs.d.ts +0 -42
- package/src/outLib/FunctionLibs.js +0 -48
- package/src/outLib/Observable.d.ts +0 -130
- package/src/outLib/Observable.js +0 -131
- package/src/outLib/OrderedObservable.d.ts +0 -59
- package/src/outLib/OrderedObservable.js +0 -59
- package/src/outLib/OrderedSubscribeObject.d.ts +0 -43
- package/src/outLib/OrderedSubscribeObject.js +0 -43
- package/src/outLib/Pipe.d.ts +0 -88
- package/src/outLib/Pipe.js +0 -81
- package/src/outLib/SubscribeObject.d.ts +0 -65
- package/src/outLib/SubscribeObject.js +0 -67
- package/src/outLib/Types.d.ts +0 -562
package/src/outLib/Pipe.d.ts
CHANGED
|
@@ -1,108 +1,20 @@
|
|
|
1
1
|
import { ICallback, IChainCallback, IErrorCallback, IListener, IPipeCase, IPipePayload, ISetObservableValue, ISetup, ISubscribe, ISubscriptionLike } from "./Types";
|
|
2
2
|
import { SwitchCase } from "./AbstractSwitchCase";
|
|
3
|
-
/**
|
|
4
|
-
* An abstract class that provides a flexible pipeline mechanism to process and transform streamed data.
|
|
5
|
-
* The `Pipe` class allows chaining of operations, conditional transformations, and controlled subscription handling.
|
|
6
|
-
*
|
|
7
|
-
* @template T The type of data handled by this pipeline.
|
|
8
|
-
*/
|
|
9
3
|
export declare abstract class Pipe<T> implements ISubscribe<T> {
|
|
10
4
|
chain: IChainCallback[];
|
|
11
5
|
flow: IPipePayload;
|
|
12
|
-
/**
|
|
13
|
-
* Subscribes a listener to observe changes or updates. Can optionally handle errors during the subscription process.
|
|
14
|
-
*
|
|
15
|
-
* @param {IListener<T> | ISetObservableValue} listener - The listener or handler that will receive notifications of updates.
|
|
16
|
-
* @param {IErrorCallback} [errorHandler] - An optional callback to handle errors that occur during subscription.
|
|
17
|
-
* @return {ISubscriptionLike | undefined} An object representing the subscription, or undefined if the subscription could not be created.
|
|
18
|
-
*/
|
|
19
6
|
abstract subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
20
7
|
private push;
|
|
21
|
-
/**
|
|
22
|
-
* Subscribes to an event and ensures the listener is called only once.
|
|
23
|
-
* After the listener is invoked, it unsubscribes automatically.
|
|
24
|
-
*
|
|
25
|
-
* @return {ISubscribe<T>} The subscription instance allowing further chaining or management.
|
|
26
|
-
*/
|
|
27
8
|
setOnce(): ISubscribe<T>;
|
|
28
|
-
/**
|
|
29
|
-
* Unsubscribes based on a given condition. The condition is evaluated against
|
|
30
|
-
* the payload, and if the condition returns true, the subscription is marked
|
|
31
|
-
* for unsubscription.
|
|
32
|
-
*
|
|
33
|
-
* @param {ICallback<T>} condition - A callback function that determines whether a
|
|
34
|
-
* subscription should be unsubscribed. It receives the payload as an argument
|
|
35
|
-
* and should return a boolean value.
|
|
36
|
-
* @return {ISetup<T>} The current setup instance for chaining purposes.
|
|
37
|
-
*/
|
|
38
9
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
39
|
-
/**
|
|
40
|
-
* Applies a refinement condition to the workflow pipeline.
|
|
41
|
-
*
|
|
42
|
-
* @param {ICallback<T>} condition - A callback function that evaluates a condition
|
|
43
|
-
* on the payload data and returns a boolean.
|
|
44
|
-
* @return {ISetup<T>} Returns the updated setup with the refined condition applied.
|
|
45
|
-
*/
|
|
46
10
|
refine(condition: ICallback<T>): ISetup<T>;
|
|
47
|
-
/**
|
|
48
|
-
* Adds an array of conditions to be processed by the refinement function.
|
|
49
|
-
*
|
|
50
|
-
* @param {ICallback<any>[]} conditions - An array of callback functions to be refined.
|
|
51
|
-
* @return {ISetup<T>} The current setup instance after processing the conditions.
|
|
52
|
-
*/
|
|
53
11
|
pushRefiners(conditions: ICallback<any>[]): ISetup<T>;
|
|
54
|
-
/**
|
|
55
|
-
* Creates and returns a new instance of the PipeSwitchCase class,
|
|
56
|
-
* enabling conditional logic or case-switch handling for the current context.
|
|
57
|
-
*
|
|
58
|
-
* @return {PipeSwitchCase<T>} A new instance of PipeSwitchCase associated with the current context.
|
|
59
|
-
*/
|
|
60
12
|
switch(): PipeSwitchCase<T>;
|
|
61
|
-
/**
|
|
62
|
-
* Registers a condition callback to be executed within the pipeline and modifies the payload of the current data.
|
|
63
|
-
* The condition is applied to the current payload and sets a flag indicating its availability.
|
|
64
|
-
*
|
|
65
|
-
* @param {ICallback<T>} condition - The callback function to execute on the current payload. It processes the payload and returns a new value.
|
|
66
|
-
* @return {ISetup<K>} An instance of the setup interface, allowing further chaining of operations.
|
|
67
|
-
*/
|
|
68
13
|
then<K>(condition: ICallback<T>): ISetup<K>;
|
|
69
|
-
/**
|
|
70
|
-
* Serializes the payload of the given data object into a JSON string and
|
|
71
|
-
* sets the `isAvailable` property to true.
|
|
72
|
-
*
|
|
73
|
-
* @return {ISetup<string>} The modified setup instance with the serialized payload.
|
|
74
|
-
*/
|
|
75
14
|
serialize(): ISetup<string>;
|
|
76
|
-
/**
|
|
77
|
-
* Deserializes the payload of the provided data into a JavaScript object using JSON.parse
|
|
78
|
-
* and marks the data as available.
|
|
79
|
-
*
|
|
80
|
-
* @template K - The type of the setup to be returned.
|
|
81
|
-
* @return {ISetup<K>} The setup instance after deserializing the payload.
|
|
82
|
-
*/
|
|
83
15
|
deserialize<K>(): ISetup<K>;
|
|
84
|
-
/**
|
|
85
|
-
* Processes a chain of functions with the given listener and flow data.
|
|
86
|
-
*
|
|
87
|
-
* @param {IListener<T>} listener - The listener to be executed after the chain is processed.
|
|
88
|
-
* Receives the payload of the flow data.
|
|
89
|
-
* @return {void} This method does not return a value.
|
|
90
|
-
*/
|
|
91
16
|
processChain(listener: IListener<T>): void;
|
|
92
17
|
}
|
|
93
|
-
/**
|
|
94
|
-
* The `PipeSwitchCase` class extends the functionality of the `SwitchCase`
|
|
95
|
-
* class, tailored for use with `Pipe` objects. It provides a mechanism for
|
|
96
|
-
* managing and subscribing to a pipeline of transformations or processes
|
|
97
|
-
* conditioned by specific cases.
|
|
98
|
-
*
|
|
99
|
-
* This class also implements `ISubscribe` to allow subscription to the
|
|
100
|
-
* underlying pipeline for observing or reacting to its events or values.
|
|
101
|
-
*
|
|
102
|
-
* @template T The type of the data being handled by the `PipeSwitchCase`.
|
|
103
|
-
* @extends {SwitchCase<T, Pipe<T>, IPipeCase<T>>}
|
|
104
|
-
* @implements {ISubscribe<T>}
|
|
105
|
-
*/
|
|
106
18
|
export declare class PipeSwitchCase<T> extends SwitchCase<T, Pipe<T>, IPipeCase<T>> implements ISubscribe<T> {
|
|
107
19
|
subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
108
20
|
}
|
package/src/outLib/Pipe.js
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PipeSwitchCase = exports.Pipe = void 0;
|
|
4
4
|
const AbstractSwitchCase_1 = require("./AbstractSwitchCase");
|
|
5
|
-
/**
|
|
6
|
-
* An abstract class that provides a flexible pipeline mechanism to process and transform streamed data.
|
|
7
|
-
* The `Pipe` class allows chaining of operations, conditional transformations, and controlled subscription handling.
|
|
8
|
-
*
|
|
9
|
-
* @template T The type of data handled by this pipeline.
|
|
10
|
-
*/
|
|
11
5
|
class Pipe {
|
|
12
6
|
chain = [];
|
|
13
7
|
flow = { isBreak: false, isUnsubscribe: false, isAvailable: false, payload: null };
|
|
@@ -15,28 +9,12 @@ class Pipe {
|
|
|
15
9
|
this.chain.push(callback);
|
|
16
10
|
return this;
|
|
17
11
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Subscribes to an event and ensures the listener is called only once.
|
|
20
|
-
* After the listener is invoked, it unsubscribes automatically.
|
|
21
|
-
*
|
|
22
|
-
* @return {ISubscribe<T>} The subscription instance allowing further chaining or management.
|
|
23
|
-
*/
|
|
24
12
|
setOnce() {
|
|
25
13
|
return this.push((data) => {
|
|
26
14
|
this.listener(data.payload);
|
|
27
15
|
data.isUnsubscribe = true;
|
|
28
16
|
});
|
|
29
17
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Unsubscribes based on a given condition. The condition is evaluated against
|
|
32
|
-
* the payload, and if the condition returns true, the subscription is marked
|
|
33
|
-
* for unsubscription.
|
|
34
|
-
*
|
|
35
|
-
* @param {ICallback<T>} condition - A callback function that determines whether a
|
|
36
|
-
* subscription should be unsubscribed. It receives the payload as an argument
|
|
37
|
-
* and should return a boolean value.
|
|
38
|
-
* @return {ISetup<T>} The current setup instance for chaining purposes.
|
|
39
|
-
*/
|
|
40
18
|
unsubscribeBy(condition) {
|
|
41
19
|
return this.push((data) => {
|
|
42
20
|
data.isAvailable = true;
|
|
@@ -44,22 +22,9 @@ class Pipe {
|
|
|
44
22
|
data.isUnsubscribe = true;
|
|
45
23
|
});
|
|
46
24
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Applies a refinement condition to the workflow pipeline.
|
|
49
|
-
*
|
|
50
|
-
* @param {ICallback<T>} condition - A callback function that evaluates a condition
|
|
51
|
-
* on the payload data and returns a boolean.
|
|
52
|
-
* @return {ISetup<T>} Returns the updated setup with the refined condition applied.
|
|
53
|
-
*/
|
|
54
25
|
refine(condition) {
|
|
55
26
|
return this.push((data) => condition(data.payload) && (data.isAvailable = true));
|
|
56
27
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Adds an array of conditions to be processed by the refinement function.
|
|
59
|
-
*
|
|
60
|
-
* @param {ICallback<any>[]} conditions - An array of callback functions to be refined.
|
|
61
|
-
* @return {ISetup<T>} The current setup instance after processing the conditions.
|
|
62
|
-
*/
|
|
63
28
|
pushRefiners(conditions) {
|
|
64
29
|
if (!Array.isArray(conditions))
|
|
65
30
|
return this;
|
|
@@ -67,60 +32,27 @@ class Pipe {
|
|
|
67
32
|
this.refine(conditions[i]);
|
|
68
33
|
return this;
|
|
69
34
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Creates and returns a new instance of the PipeSwitchCase class,
|
|
72
|
-
* enabling conditional logic or case-switch handling for the current context.
|
|
73
|
-
*
|
|
74
|
-
* @return {PipeSwitchCase<T>} A new instance of PipeSwitchCase associated with the current context.
|
|
75
|
-
*/
|
|
76
35
|
switch() {
|
|
77
36
|
return new PipeSwitchCase(this);
|
|
78
37
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Registers a condition callback to be executed within the pipeline and modifies the payload of the current data.
|
|
81
|
-
* The condition is applied to the current payload and sets a flag indicating its availability.
|
|
82
|
-
*
|
|
83
|
-
* @param {ICallback<T>} condition - The callback function to execute on the current payload. It processes the payload and returns a new value.
|
|
84
|
-
* @return {ISetup<K>} An instance of the setup interface, allowing further chaining of operations.
|
|
85
|
-
*/
|
|
86
38
|
then(condition) {
|
|
87
39
|
return this.push((data) => {
|
|
88
40
|
data.payload = condition(data.payload);
|
|
89
41
|
data.isAvailable = true;
|
|
90
42
|
});
|
|
91
43
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Serializes the payload of the given data object into a JSON string and
|
|
94
|
-
* sets the `isAvailable` property to true.
|
|
95
|
-
*
|
|
96
|
-
* @return {ISetup<string>} The modified setup instance with the serialized payload.
|
|
97
|
-
*/
|
|
98
44
|
serialize() {
|
|
99
45
|
return this.push((data) => {
|
|
100
46
|
data.payload = JSON.stringify(data.payload);
|
|
101
47
|
data.isAvailable = true;
|
|
102
48
|
});
|
|
103
49
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Deserializes the payload of the provided data into a JavaScript object using JSON.parse
|
|
106
|
-
* and marks the data as available.
|
|
107
|
-
*
|
|
108
|
-
* @template K - The type of the setup to be returned.
|
|
109
|
-
* @return {ISetup<K>} The setup instance after deserializing the payload.
|
|
110
|
-
*/
|
|
111
50
|
deserialize() {
|
|
112
51
|
return this.push((data) => {
|
|
113
52
|
data.payload = JSON.parse(data.payload);
|
|
114
53
|
data.isAvailable = true;
|
|
115
54
|
});
|
|
116
55
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Processes a chain of functions with the given listener and flow data.
|
|
119
|
-
*
|
|
120
|
-
* @param {IListener<T>} listener - The listener to be executed after the chain is processed.
|
|
121
|
-
* Receives the payload of the flow data.
|
|
122
|
-
* @return {void} This method does not return a value.
|
|
123
|
-
*/
|
|
124
56
|
processChain(listener) {
|
|
125
57
|
const chain = this.chain;
|
|
126
58
|
const data = this.flow;
|
|
@@ -140,19 +72,6 @@ class Pipe {
|
|
|
140
72
|
}
|
|
141
73
|
}
|
|
142
74
|
exports.Pipe = Pipe;
|
|
143
|
-
/**
|
|
144
|
-
* The `PipeSwitchCase` class extends the functionality of the `SwitchCase`
|
|
145
|
-
* class, tailored for use with `Pipe` objects. It provides a mechanism for
|
|
146
|
-
* managing and subscribing to a pipeline of transformations or processes
|
|
147
|
-
* conditioned by specific cases.
|
|
148
|
-
*
|
|
149
|
-
* This class also implements `ISubscribe` to allow subscription to the
|
|
150
|
-
* underlying pipeline for observing or reacting to its events or values.
|
|
151
|
-
*
|
|
152
|
-
* @template T The type of the data being handled by the `PipeSwitchCase`.
|
|
153
|
-
* @extends {SwitchCase<T, Pipe<T>, IPipeCase<T>>}
|
|
154
|
-
* @implements {ISubscribe<T>}
|
|
155
|
-
*/
|
|
156
75
|
class PipeSwitchCase extends AbstractSwitchCase_1.SwitchCase {
|
|
157
76
|
subscribe(listener, errorHandler) {
|
|
158
77
|
return this.pipe.subscribe(listener, errorHandler);
|
|
@@ -1,83 +1,18 @@
|
|
|
1
1
|
import { IErrorCallback, IListener, IObserver, ISubscribeGroup, ISubscribeObject, ISubscriptionLike } from "./Types";
|
|
2
2
|
import { Pipe } from "./Pipe";
|
|
3
|
-
/**
|
|
4
|
-
* A class that represents an observable object with subscription, pausing,
|
|
5
|
-
* and piping functionalities. It allows subscribing to updates, handling errors,
|
|
6
|
-
* and processing values through a chain.
|
|
7
|
-
*
|
|
8
|
-
* @template T The type of values handled by SubscribeObject.
|
|
9
|
-
* @extends Pipe<T>
|
|
10
|
-
* @implements ISubscribeObject<T>
|
|
11
|
-
*/
|
|
12
3
|
export declare class SubscribeObject<T> extends Pipe<T> implements ISubscribeObject<T> {
|
|
13
4
|
observer: IObserver<T> | undefined;
|
|
14
5
|
listener: IListener<T> | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* A callback function used for handling errors in the context of the SubscribeObject.
|
|
17
|
-
* This function logs the provided error data and error message to the console for debugging purposes.
|
|
18
|
-
*
|
|
19
|
-
* @type {IErrorCallback}
|
|
20
|
-
* @param {any} errorData - The data related to the error encountered.
|
|
21
|
-
* @param {any} errorMessage - A descriptive message detailing the error.
|
|
22
|
-
*/
|
|
23
6
|
errorHandler: IErrorCallback;
|
|
24
7
|
_order: number;
|
|
25
8
|
paused: boolean;
|
|
26
9
|
piped: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Constructs an instance of the class.
|
|
29
|
-
*
|
|
30
|
-
* @param {IObserver<T>} [observable] - The observer instance to be assigned. Optional parameter.
|
|
31
|
-
* @param {boolean} [isPipe=false] - Determines whether the instance is piped. Defaults to false.
|
|
32
|
-
* @return {void}
|
|
33
|
-
*/
|
|
34
10
|
constructor(observable?: IObserver<T>, isPipe?: boolean);
|
|
35
|
-
/**
|
|
36
|
-
* Subscribes an observer to the current instance and optionally assigns an error handler.
|
|
37
|
-
*
|
|
38
|
-
* @param {ISubscribeGroup<T>} observer - The observer group to subscribe.
|
|
39
|
-
* @param {IErrorCallback} [errorHandler] - Optional callback to handle errors.
|
|
40
|
-
* @return {ISubscriptionLike} An instance representing the subscription.
|
|
41
|
-
*/
|
|
42
11
|
subscribe(observer: ISubscribeGroup<T>, errorHandler?: IErrorCallback): ISubscriptionLike;
|
|
43
|
-
/**
|
|
44
|
-
* Unsubscribes the current instance from the associated observer, clears the listener,
|
|
45
|
-
* and resets the internal chain.
|
|
46
|
-
* This method ensures that the instance is properly cleaned up and no longer receives updates.
|
|
47
|
-
*
|
|
48
|
-
* @return {void} Does not return a value.
|
|
49
|
-
*/
|
|
50
12
|
unsubscribe(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Sends the specified value for processing and updates the flow state.
|
|
53
|
-
*
|
|
54
|
-
* @param {T} value - The value to be sent and processed.
|
|
55
|
-
* @return {void} Does not return a value.
|
|
56
|
-
*/
|
|
57
13
|
send(value: T): void;
|
|
58
|
-
/**
|
|
59
|
-
* Resumes the current process or operation from a paused state.
|
|
60
|
-
* Updates the internal state to indicate that it is no longer paused.
|
|
61
|
-
*
|
|
62
|
-
* @return {void} Does not return a value.
|
|
63
|
-
*/
|
|
64
14
|
resume(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Pauses the current operation or process by setting the paused state to true.
|
|
67
|
-
*
|
|
68
|
-
* @return {void} No value is returned.
|
|
69
|
-
*/
|
|
70
15
|
pause(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves the current order value.
|
|
73
|
-
*
|
|
74
|
-
* @return {number} The current value of the order.
|
|
75
|
-
*/
|
|
76
16
|
get order(): number;
|
|
77
|
-
/**
|
|
78
|
-
* Sets the order value.
|
|
79
|
-
*
|
|
80
|
-
* @param {number} value - The numerical value to set as the order.
|
|
81
|
-
*/
|
|
82
17
|
set order(value: number);
|
|
83
18
|
}
|
|
@@ -3,63 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SubscribeObject = void 0;
|
|
4
4
|
const Pipe_1 = require("./Pipe");
|
|
5
5
|
const FunctionLibs_1 = require("./FunctionLibs");
|
|
6
|
-
/**
|
|
7
|
-
* A class that represents an observable object with subscription, pausing,
|
|
8
|
-
* and piping functionalities. It allows subscribing to updates, handling errors,
|
|
9
|
-
* and processing values through a chain.
|
|
10
|
-
*
|
|
11
|
-
* @template T The type of values handled by SubscribeObject.
|
|
12
|
-
* @extends Pipe<T>
|
|
13
|
-
* @implements ISubscribeObject<T>
|
|
14
|
-
*/
|
|
15
6
|
class SubscribeObject extends Pipe_1.Pipe {
|
|
16
7
|
observer;
|
|
17
8
|
listener;
|
|
18
|
-
/**
|
|
19
|
-
* A callback function used for handling errors in the context of the SubscribeObject.
|
|
20
|
-
* This function logs the provided error data and error message to the console for debugging purposes.
|
|
21
|
-
*
|
|
22
|
-
* @type {IErrorCallback}
|
|
23
|
-
* @param {any} errorData - The data related to the error encountered.
|
|
24
|
-
* @param {any} errorMessage - A descriptive message detailing the error.
|
|
25
|
-
*/
|
|
26
9
|
errorHandler = (errorData, errorMessage) => {
|
|
27
10
|
console.log(`(Unit of SubscribeObject).send(${errorData}) ERROR:`, errorMessage);
|
|
28
11
|
};
|
|
29
12
|
_order = 0;
|
|
30
13
|
paused = false;
|
|
31
14
|
piped = false;
|
|
32
|
-
/**
|
|
33
|
-
* Constructs an instance of the class.
|
|
34
|
-
*
|
|
35
|
-
* @param {IObserver<T>} [observable] - The observer instance to be assigned. Optional parameter.
|
|
36
|
-
* @param {boolean} [isPipe=false] - Determines whether the instance is piped. Defaults to false.
|
|
37
|
-
* @return {void}
|
|
38
|
-
*/
|
|
39
15
|
constructor(observable, isPipe) {
|
|
40
16
|
super();
|
|
41
17
|
this.observer = observable;
|
|
42
18
|
this.piped = !!isPipe;
|
|
43
19
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Subscribes an observer to the current instance and optionally assigns an error handler.
|
|
46
|
-
*
|
|
47
|
-
* @param {ISubscribeGroup<T>} observer - The observer group to subscribe.
|
|
48
|
-
* @param {IErrorCallback} [errorHandler] - Optional callback to handle errors.
|
|
49
|
-
* @return {ISubscriptionLike} An instance representing the subscription.
|
|
50
|
-
*/
|
|
51
20
|
subscribe(observer, errorHandler) {
|
|
52
21
|
this.listener = (0, FunctionLibs_1.getListener)(observer);
|
|
53
22
|
errorHandler && (this.errorHandler = errorHandler);
|
|
54
23
|
return this;
|
|
55
24
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Unsubscribes the current instance from the associated observer, clears the listener,
|
|
58
|
-
* and resets the internal chain.
|
|
59
|
-
* This method ensures that the instance is properly cleaned up and no longer receives updates.
|
|
60
|
-
*
|
|
61
|
-
* @return {void} Does not return a value.
|
|
62
|
-
*/
|
|
63
25
|
unsubscribe() {
|
|
64
26
|
if (!this.observer)
|
|
65
27
|
return;
|
|
@@ -68,12 +30,6 @@ class SubscribeObject extends Pipe_1.Pipe {
|
|
|
68
30
|
this.listener = null;
|
|
69
31
|
this.chain.length = 0;
|
|
70
32
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Sends the specified value for processing and updates the flow state.
|
|
73
|
-
*
|
|
74
|
-
* @param {T} value - The value to be sent and processed.
|
|
75
|
-
* @return {void} Does not return a value.
|
|
76
|
-
*/
|
|
77
33
|
send(value) {
|
|
78
34
|
const listener = this.listener;
|
|
79
35
|
if (!listener) {
|
|
@@ -82,7 +38,6 @@ class SubscribeObject extends Pipe_1.Pipe {
|
|
|
82
38
|
}
|
|
83
39
|
if (!this.observer || this.paused)
|
|
84
40
|
return;
|
|
85
|
-
// Fast path (no pipe)
|
|
86
41
|
if (!this.piped) {
|
|
87
42
|
try {
|
|
88
43
|
listener(value);
|
|
@@ -92,7 +47,6 @@ class SubscribeObject extends Pipe_1.Pipe {
|
|
|
92
47
|
}
|
|
93
48
|
return;
|
|
94
49
|
}
|
|
95
|
-
// Slow path (with pipe)
|
|
96
50
|
try {
|
|
97
51
|
this.flow.payload = value;
|
|
98
52
|
this.flow.isBreak = false;
|
|
@@ -102,36 +56,15 @@ class SubscribeObject extends Pipe_1.Pipe {
|
|
|
102
56
|
this.errorHandler(value, err);
|
|
103
57
|
}
|
|
104
58
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Resumes the current process or operation from a paused state.
|
|
107
|
-
* Updates the internal state to indicate that it is no longer paused.
|
|
108
|
-
*
|
|
109
|
-
* @return {void} Does not return a value.
|
|
110
|
-
*/
|
|
111
59
|
resume() {
|
|
112
60
|
this.paused = false;
|
|
113
61
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Pauses the current operation or process by setting the paused state to true.
|
|
116
|
-
*
|
|
117
|
-
* @return {void} No value is returned.
|
|
118
|
-
*/
|
|
119
62
|
pause() {
|
|
120
63
|
this.paused = true;
|
|
121
64
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Retrieves the current order value.
|
|
124
|
-
*
|
|
125
|
-
* @return {number} The current value of the order.
|
|
126
|
-
*/
|
|
127
65
|
get order() {
|
|
128
66
|
return this._order;
|
|
129
67
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Sets the order value.
|
|
132
|
-
*
|
|
133
|
-
* @param {number} value - The numerical value to set as the order.
|
|
134
|
-
*/
|
|
135
68
|
set order(value) {
|
|
136
69
|
this._order = value;
|
|
137
70
|
}
|