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/Types.d.ts
CHANGED
|
@@ -1,726 +1,164 @@
|
|
|
1
1
|
import { PipeSwitchCase } from "./Pipe";
|
|
2
2
|
import { FilterSwitchCase } from "./FilterCollection";
|
|
3
|
-
/**
|
|
4
|
-
* Defines a callback function type that can be invoked with an optional value of type `T`.
|
|
5
|
-
* The function can perform any operation and optionally return a value of any type.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the parameter that the callback function may receive.
|
|
8
|
-
* @param {T} [value] - An optional parameter of type `T` passed to the callback function.
|
|
9
|
-
* @returns {any} - The return type of the callback function is not specified and can be of any type.
|
|
10
|
-
*/
|
|
11
3
|
export type ICallback<T> = (value?: T) => any;
|
|
12
|
-
/**
|
|
13
|
-
* Represents a callback function to handle error scenarios.
|
|
14
|
-
*
|
|
15
|
-
* This type defines a function signature that accepts error-related data
|
|
16
|
-
* and a descriptive error message as parameters and performs an operation.
|
|
17
|
-
*
|
|
18
|
-
* @callback IErrorCallback
|
|
19
|
-
* @param {any} errorData - The data or object representing the error.
|
|
20
|
-
* @param {any} errorMessage - A descriptive message providing details about the error.
|
|
21
|
-
*/
|
|
22
4
|
export type IErrorCallback = (errorData: any, errorMessage: any) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Represents a contract for subscribing to a data stream or event source.
|
|
25
|
-
*
|
|
26
|
-
* @template T The type of data or events being subscribed to.
|
|
27
|
-
*
|
|
28
|
-
* @property subscribe Provides the mechanism to register a listener for handling incoming data or events,
|
|
29
|
-
* and optionally handles errors.
|
|
30
|
-
* - `listener` is the callback that processes the data or events.
|
|
31
|
-
* - `errorHandler` is an optional callback for handling errors during the subscription.
|
|
32
|
-
* - Returns an object implementing `ISubscriptionLike` to manage the subscription, or `undefined` if no subscription is created.
|
|
33
|
-
*/
|
|
34
5
|
export type ISubscribe<T> = {
|
|
35
6
|
subscribe(listener: ISubscribeGroup<T>, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
|
|
36
7
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Represents a listener interface that extends the functionality of `ICallback`.
|
|
39
|
-
* This type is designed to handle events, callbacks, or notifications with a specific type `T`.
|
|
40
|
-
*
|
|
41
|
-
* Generic:
|
|
42
|
-
* @template T - The type of data that the listener will handle.
|
|
43
|
-
*/
|
|
44
8
|
export type IListener<T> = ICallback<T>;
|
|
45
|
-
/**
|
|
46
|
-
* IDestroy represents an interface for objects that can be destroyed to release resources.
|
|
47
|
-
* It provides a method to perform the destroy operation and a property to indicate if the object is already destroyed.
|
|
48
|
-
*
|
|
49
|
-
* Members:
|
|
50
|
-
* - destroy(): A method to perform cleanup and release resources associated with the object.
|
|
51
|
-
* - isDestroyed: A boolean property that reflects whether the object has been destroyed.
|
|
52
|
-
*/
|
|
53
9
|
export type IDestroy = {
|
|
54
10
|
destroy(): void;
|
|
55
11
|
isDestroyed: boolean;
|
|
56
12
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Represents an order with a specific numerical value.
|
|
59
|
-
* Defines a structure to hold the order information as a numeric value.
|
|
60
|
-
*/
|
|
61
13
|
export type IOrder = {
|
|
62
14
|
order: number;
|
|
63
15
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Represents a generic switch interface.
|
|
66
|
-
*
|
|
67
|
-
* @template T The type of the value to be used in the switch operation.
|
|
68
|
-
*
|
|
69
|
-
* @property {Function} switch - Defines the method for initiating a switch operation.
|
|
70
|
-
* Returns a `PipeSwitchCase<T>` representing the next step in the switching process.
|
|
71
|
-
*/
|
|
72
16
|
export type ISwitch<T> = {
|
|
73
17
|
switch(): PipeSwitchCase<T>;
|
|
74
18
|
};
|
|
75
|
-
/**
|
|
76
|
-
* Represents an interface for an ordered switch mechanism that evaluates
|
|
77
|
-
* conditions in a specific sequence and invokes the corresponding logic.
|
|
78
|
-
*
|
|
79
|
-
* This interface is generic and designed to operate with a specific type `T`.
|
|
80
|
-
*
|
|
81
|
-
* @template T The type of data expected by the implementation.
|
|
82
|
-
* @property switch A method intended to handle the ordered evaluation of cases
|
|
83
|
-
* and return an instance of `PipeSwitchCase<T>`.
|
|
84
|
-
*/
|
|
85
19
|
export type IOrderedSwitch<T> = {
|
|
86
20
|
switch(): PipeSwitchCase<T>;
|
|
87
21
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Represents an interface defining a contract for a one-time settable subscription mechanism.
|
|
90
|
-
*
|
|
91
|
-
* @template T - The type of the data or value associated with the subscription.
|
|
92
|
-
*
|
|
93
|
-
* @property setOnce - A method that ensures the associated subscription can only be set or triggered once.
|
|
94
|
-
* @returns {ISubscribe<T>} - An instance of ISubscribe with the generic type T.
|
|
95
|
-
*/
|
|
96
22
|
export type IOnce<T> = {
|
|
97
23
|
setOnce(): ISubscribe<T>;
|
|
98
24
|
};
|
|
99
|
-
/**
|
|
100
|
-
* Represents an interface that ensures an ordered item can be set only once.
|
|
101
|
-
*
|
|
102
|
-
* @template T - The type of item to be handled by the implementation.
|
|
103
|
-
*/
|
|
104
25
|
export type IOrderedOnce<T> = {
|
|
105
26
|
setOnce(): IOrderedSubscribe<T>;
|
|
106
27
|
};
|
|
107
|
-
/**
|
|
108
|
-
* Interface representing an observable value that can be updated by emitting a new value.
|
|
109
|
-
*
|
|
110
|
-
* ISetObservableValue provides a `next` method that allows sending new values to be observed by subscribers.
|
|
111
|
-
*/
|
|
112
28
|
export type ISetObservableValue = {
|
|
113
29
|
next(value: any): void;
|
|
114
30
|
};
|
|
115
|
-
/**
|
|
116
|
-
* Represents a subscription-like object which provides a mechanism to release resources or
|
|
117
|
-
* cancelable operations when they are no longer needed.
|
|
118
|
-
*
|
|
119
|
-
* This type defines a structure that requires an `unsubscribe` method, allowing consumers
|
|
120
|
-
* to implement custom behavior or cleanup logic when the subscription is no longer active.
|
|
121
|
-
*/
|
|
122
31
|
export type ISubscriptionLike = {
|
|
123
32
|
unsubscribe(): void;
|
|
124
33
|
};
|
|
125
|
-
/**
|
|
126
|
-
* Represents a composite interface that combines multiple functionalities for handling events, transformations, and subscriptions in a generic way.
|
|
127
|
-
*
|
|
128
|
-
* @template T The type of the data or events processed by the setup.
|
|
129
|
-
* @typedef {object} ISetup<T>
|
|
130
|
-
* @property {IUnsubscribeByPositive<T>} Implements unsubscribe functionality based on positive filters or criteria.
|
|
131
|
-
* @property {IEmitByPositive<T>} Implements emission functionality for events based on positive conditions.
|
|
132
|
-
* @property {IOnce<T>} Provides mechanisms for handling one-time subscriptions.
|
|
133
|
-
* @property {ISwitch<T>} Interface for enabling switch-like behavior for managing state or event streams.
|
|
134
|
-
* @property {ITransform<T>} Allows for the transformation of data or events before they are processed or re-emitted.
|
|
135
|
-
* @property {ISerialisation} Includes methods for serializing and deserializing data structures.
|
|
136
|
-
* @property {ISubscribe<T>} Implements standard subscription management functionalities.
|
|
137
|
-
*/
|
|
138
34
|
export type ISetup<T> = IUnsubscribeByPositive<T> & IEmitByPositive<T> & IOnce<T> & ISwitch<T> & ITransform<T> & ISerialisation & ISubscribe<T>;
|
|
139
|
-
/**
|
|
140
|
-
* Represents an ordered setup configuration that combines multiple ordered operations
|
|
141
|
-
* related to subscribing, emitting, transforming, serializing, and other functionalities.
|
|
142
|
-
* This type extends various ordered operation interfaces to provide a comprehensive
|
|
143
|
-
* structure for managing ordered processing of type T data.
|
|
144
|
-
*
|
|
145
|
-
* It includes the following features:
|
|
146
|
-
* - Unsubscription handling in an ordered manner.
|
|
147
|
-
* - Event emission management with positive ordering.
|
|
148
|
-
* - One-time execution of operations.
|
|
149
|
-
* - Switching between different ordered setups.
|
|
150
|
-
* - Transformation of data in an ordered way.
|
|
151
|
-
* - Serialization and deserialization capabilities.
|
|
152
|
-
* - Subscription management adhering to order.
|
|
153
|
-
*
|
|
154
|
-
* @template T The type of the data to be handled by the ordered setup.
|
|
155
|
-
*/
|
|
156
35
|
export type IOrderedSetup<T> = IOrderedUnsubscribeByPositive<T> & IOrderedEmitByPositive<T> & IOrderedOnce<T> & IOrderedSwitch<T> & IOrderedTransform<T> & IOrderedSerialisation & IOrderedSubscribe<T>;
|
|
157
|
-
/**
|
|
158
|
-
* Represents a composite type that combines several interfaces to define
|
|
159
|
-
* the behavior and properties of a subscription object with extended
|
|
160
|
-
* features.
|
|
161
|
-
*
|
|
162
|
-
* @template T The type of data being interacted with in the subscription object.
|
|
163
|
-
*
|
|
164
|
-
* @extends ISubscriptionLike Represents the basic structure for subscription-like objects.
|
|
165
|
-
* @extends IPause Provides the ability to pause and resume functionality.
|
|
166
|
-
* @extends IOrder Adds capabilities for managing ordered processing or priority.
|
|
167
|
-
* @extends ISend<T> Includes sending data functionality with type T.
|
|
168
|
-
* @extends ISetup<T> Incorporates setup or initialization procedures with type T.
|
|
169
|
-
*/
|
|
170
36
|
export type ISubscribeObject<T> = ISubscriptionLike & IPause & IOrder & ISend<T> & ISetup<T>;
|
|
171
|
-
/**
|
|
172
|
-
* Represents a counter interface for subscriptions.
|
|
173
|
-
* An ISubscribeCounter instance provides methods to query the size
|
|
174
|
-
* of the collection or group being managed.
|
|
175
|
-
*/
|
|
176
37
|
export type ISubscribeCounter = {
|
|
177
38
|
size(): number;
|
|
178
39
|
};
|
|
179
|
-
/**
|
|
180
|
-
* Interface representing a subscriber that can hold a value and has a subscription mechanism.
|
|
181
|
-
* Combines the functionalities of value retrieval and subscription handling.
|
|
182
|
-
*
|
|
183
|
-
* @template T - The type of the value that the subscriber holds.
|
|
184
|
-
*
|
|
185
|
-
* @property {boolean} isEnable - Indicates whether the subscriber is currently enabled.
|
|
186
|
-
*
|
|
187
|
-
* @method getValue
|
|
188
|
-
* Retrieves the current value held by the subscriber.
|
|
189
|
-
* @returns {T | undefined} The current value of type T if available, or undefined if not set.
|
|
190
|
-
*
|
|
191
|
-
* @extends ISubscribe
|
|
192
|
-
*/
|
|
193
40
|
export type ISubscriber<T> = {
|
|
194
41
|
getValue(): T | undefined;
|
|
195
42
|
isEnable: boolean;
|
|
196
43
|
} & ISubscribe<T>;
|
|
197
|
-
/**
|
|
198
|
-
* An interface representing an Observer with extended functionalities for managing subscriptions,
|
|
199
|
-
* controlling observability, and interacting with subscriber-related behavior.
|
|
200
|
-
*
|
|
201
|
-
* @template T - The type of the observed value.
|
|
202
|
-
*
|
|
203
|
-
* @extends ISetObservableValue
|
|
204
|
-
* @extends ISubscriber<T>
|
|
205
|
-
* @extends IDestroy
|
|
206
|
-
* @extends ISubscribeCounter
|
|
207
|
-
* @extends IObservablePipe<T>
|
|
208
|
-
*
|
|
209
|
-
* @property {function(ISubscriptionLike): void} unSubscribe - Removes a specific subscriber from the observer.
|
|
210
|
-
* @property {function(): void} unsubscribeAll - Removes all subscribers from the observer.
|
|
211
|
-
* @property {function(): void} disable - Temporarily disables the observer, preventing it from notifying subscribers.
|
|
212
|
-
* @property {function(): void} enable - Re-enables the observer, allowing it to notify subscribers.
|
|
213
|
-
*/
|
|
214
44
|
export type IObserver<T> = ISetObservableValue & ISubscriber<T> & IDestroy & ISubscribeCounter & IObservablePipe<T> & {
|
|
215
45
|
unSubscribe(subscriber: ISubscriptionLike): void;
|
|
216
46
|
unsubscribeAll(): void;
|
|
217
47
|
disable(): void;
|
|
218
48
|
enable(): void;
|
|
219
49
|
};
|
|
220
|
-
/**
|
|
221
|
-
* Represents a generic stream interface for processing arrays of type T.
|
|
222
|
-
*
|
|
223
|
-
* This interface defines a method to input and handle data streams.
|
|
224
|
-
*
|
|
225
|
-
* @template T The type of the data elements to be streamed.
|
|
226
|
-
* @typedef {Object} IStream
|
|
227
|
-
* @property {(value: T[]) => void} stream A method to handle an array of elements of type T.
|
|
228
|
-
*/
|
|
229
50
|
export type IStream<T> = {
|
|
230
51
|
stream(value: T[]): void;
|
|
231
52
|
};
|
|
232
|
-
/**
|
|
233
|
-
* Represents an interface for pausing and resuming operations.
|
|
234
|
-
*
|
|
235
|
-
* The IPause interface provides methods to pause and resume a process or operation.
|
|
236
|
-
* It can be used as a structure for implementing functionality where halting and continuing an activity is required.
|
|
237
|
-
*
|
|
238
|
-
* Method Summary:
|
|
239
|
-
* - `pause`: Invokes a pause in the operation.
|
|
240
|
-
* - `resume`: Resumes the operation from a paused state.
|
|
241
|
-
*/
|
|
242
53
|
export type IPause = {
|
|
243
54
|
pause(): void;
|
|
244
55
|
resume(): void;
|
|
245
56
|
};
|
|
246
|
-
/**
|
|
247
|
-
* Represents an observable pipe, which provides a mechanism to transform or manipulate a stream of data.
|
|
248
|
-
*
|
|
249
|
-
* This type defines the structure for an object with a `pipe` method. The `pipe` method is intended
|
|
250
|
-
* to configure or sequence certain operations on data of type `T` and return an optional setup structure.
|
|
251
|
-
*
|
|
252
|
-
* @template T - The type of data the observable pipe operates on.
|
|
253
|
-
* @property {Function} pipe - A method that executes the defined setup or transformation process.
|
|
254
|
-
* Returns an `ISetup<T>` instance or `undefined` if no setup is performed.
|
|
255
|
-
*/
|
|
256
57
|
export type IObservablePipe<T> = {
|
|
257
58
|
pipe(): ISetup<T> | undefined;
|
|
258
59
|
};
|
|
259
|
-
/**
|
|
260
|
-
* Represents an interface for an ordered observable pipe.
|
|
261
|
-
*
|
|
262
|
-
* @template T - The type of the value being processed through the pipe.
|
|
263
|
-
*
|
|
264
|
-
* @property {Function} pipe - A method that processes the observable stream and returns a setup.
|
|
265
|
-
* The setup may be undefined if no valid output is generated.
|
|
266
|
-
* @returns {ISetup<T> | undefined} - Returns an instance of ISetup of type T if the processing succeeds,
|
|
267
|
-
* otherwise undefined.
|
|
268
|
-
*/
|
|
269
60
|
export type IOrderedObservablePipe<T> = {
|
|
270
61
|
pipe(): ISetup<T> | undefined;
|
|
271
62
|
};
|
|
272
|
-
/**
|
|
273
|
-
* Interface ISend represents a contract for sending a value of a generic type.
|
|
274
|
-
*
|
|
275
|
-
* This interface declares a single method, `send`, which is responsible
|
|
276
|
-
* for handling the transmission or processing of the provided value.
|
|
277
|
-
*
|
|
278
|
-
* @template T - The type of the value that can be sent using this interface.
|
|
279
|
-
*/
|
|
280
63
|
export type ISend<T> = {
|
|
281
64
|
send(value: T): void;
|
|
282
65
|
};
|
|
283
|
-
/**
|
|
284
|
-
* Represents an interface that provides a method for unsubscribing actions based on a
|
|
285
|
-
* specified negative condition defined by a callback function.
|
|
286
|
-
*
|
|
287
|
-
* @template T - The type parameter that the interface will operate with.
|
|
288
|
-
*
|
|
289
|
-
* @property unsubscribeByNegative - A method to unsubscribe based on the evaluation
|
|
290
|
-
* of a condition provided through a callback.
|
|
291
|
-
*
|
|
292
|
-
* @param condition - A callback function that determines the criteria for unsubscribing.
|
|
293
|
-
* The callback may evaluate a condition on the type `T`.
|
|
294
|
-
* @returns An object of type `ISetup<T>` which represents the setup or state after
|
|
295
|
-
* the unsubscribe operation.
|
|
296
|
-
*/
|
|
297
66
|
export type IUnsubscribeByNegative<T> = {
|
|
298
67
|
unsubscribeByNegative(condition: ICallback<T>): ISetup<T>;
|
|
299
68
|
};
|
|
300
|
-
/**
|
|
301
|
-
* Represents an interface that provides a mechanism to unsubscribe using a negative condition.
|
|
302
|
-
*
|
|
303
|
-
* @template T The type of data handled by the callback function.
|
|
304
|
-
*
|
|
305
|
-
* @typedef {Object} IOrderedUnsubscribeByNegative
|
|
306
|
-
* @property {function(condition: ICallback<T>): IOrderedSetup<T>} unsubscribeByNegative
|
|
307
|
-
* A method that allows unsubscribing based on a provided negative condition.
|
|
308
|
-
* The condition is determined through the given callback function.
|
|
309
|
-
*/
|
|
310
69
|
export type IOrderedUnsubscribeByNegative<T> = {
|
|
311
70
|
unsubscribeByNegative(condition: ICallback<T>): IOrderedSetup<T>;
|
|
312
71
|
};
|
|
313
|
-
/**
|
|
314
|
-
* Represents a generic type that allows for unsubscribing based on a given condition.
|
|
315
|
-
*
|
|
316
|
-
* This type is designed to provide an interface for managing subscriptions
|
|
317
|
-
* that can be terminated by evaluating a condition specified by the user.
|
|
318
|
-
*
|
|
319
|
-
* @template T - The type of the value being processed or observed in the context
|
|
320
|
-
* of the unsubscribe operation.
|
|
321
|
-
*
|
|
322
|
-
* @property {function} unsubscribeBy - A method to unsubscribe based on a specified condition.
|
|
323
|
-
* This condition is defined as a callback function that determines whether the unsubscribe action
|
|
324
|
-
* should be performed.
|
|
325
|
-
*
|
|
326
|
-
* @param {ICallback<T>} condition - A callback function that evaluates the condition for unsubscribing.
|
|
327
|
-
* The callback should return a value indicating whether the specified condition has been met.
|
|
328
|
-
*
|
|
329
|
-
* @returns {ISetup<T>} - Returns an instance of ISetup to allow further configuration or management
|
|
330
|
-
* following the unsubscribe operation.
|
|
331
|
-
*/
|
|
332
72
|
export type IUnsubscribeByPositive<T> = {
|
|
333
73
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
334
74
|
};
|
|
335
|
-
/**
|
|
336
|
-
* Represents an interface for managing ordered unsubscription using a provided condition.
|
|
337
|
-
*
|
|
338
|
-
* @template T - The type parameter representing the data model or entity being handled.
|
|
339
|
-
*
|
|
340
|
-
* @typedef {Object} IOrderedUnsubscribeByPositive
|
|
341
|
-
* @property {(condition: ICallback<T>) => ISetup<T>} unsubscribeBy - Method to unsubscribe items based on a specific condition.
|
|
342
|
-
* Accepts a callback function that determines the criteria for unsubscription and returns the setup object associated with the operation.
|
|
343
|
-
*/
|
|
344
75
|
export type IOrderedUnsubscribeByPositive<T> = {
|
|
345
76
|
unsubscribeBy(condition: ICallback<T>): ISetup<T>;
|
|
346
77
|
};
|
|
347
|
-
/**
|
|
348
|
-
* Represents a type for an object that allows emitting events based on a negative condition.
|
|
349
|
-
*
|
|
350
|
-
* @template T The type of the value that will be passed to the callback and setup methods.
|
|
351
|
-
*
|
|
352
|
-
* @property {function(condition: ICallback<T>): ISetup<T>} emitByNegative - A method that triggers a setup process
|
|
353
|
-
* if a specified condition evaluates to a negative result.
|
|
354
|
-
*/
|
|
355
78
|
export type IEmitByNegative<T> = {
|
|
356
79
|
emitByNegative(condition: ICallback<T>): ISetup<T>;
|
|
357
80
|
};
|
|
358
|
-
/**
|
|
359
|
-
* Represents an interface for handling ordered emissions based on a negative condition.
|
|
360
|
-
*
|
|
361
|
-
* @template T - The type of the value being processed.
|
|
362
|
-
*
|
|
363
|
-
* @typedef {Object} IOrderedEmitByNegative
|
|
364
|
-
*
|
|
365
|
-
* @property {function(condition: ICallback<T>): IOrderedSetup<T>} emitByNegative -
|
|
366
|
-
* A method that determines ordered emissions of elements based on a provided
|
|
367
|
-
* condition that evaluates to a negative criteria.
|
|
368
|
-
*
|
|
369
|
-
* @callback ICallback<T>
|
|
370
|
-
* A callback function used to define the negative condition for emission.
|
|
371
|
-
*
|
|
372
|
-
* @returns {IOrderedSetup<T>}
|
|
373
|
-
* Returns an instance of IOrderedSetup<T>, facilitating further configuration
|
|
374
|
-
* of the ordered emission process based on the negative condition.
|
|
375
|
-
*/
|
|
376
81
|
export type IOrderedEmitByNegative<T> = {
|
|
377
82
|
emitByNegative(condition: ICallback<T>): IOrderedSetup<T>;
|
|
378
83
|
};
|
|
379
|
-
/**
|
|
380
|
-
* Represents a type that facilitates the refinement of conditions or rules and manages setting up these refinements.
|
|
381
|
-
*
|
|
382
|
-
* @template T - The type of data or element that the methods operate on.
|
|
383
|
-
*
|
|
384
|
-
* @typedef {Object} IEmitByPositive
|
|
385
|
-
*
|
|
386
|
-
* @property {function(condition: ICallback<T>): ISetup<T>} refine - Refines a specific condition by taking an input callback and setting it up.
|
|
387
|
-
* @property {function(conditions: ICallback<T>[]): ISetup<T>} pushRefiners - Pushes an array of callback conditions to further refine the setup process.
|
|
388
|
-
*/
|
|
389
84
|
export type IEmitByPositive<T> = {
|
|
390
85
|
refine(condition: ICallback<T>): ISetup<T>;
|
|
391
86
|
pushRefiners(conditions: ICallback<T>[]): ISetup<T>;
|
|
392
87
|
};
|
|
393
|
-
/**
|
|
394
|
-
* Represents a transformation interface that defines a chainable method to apply transformations to a value
|
|
395
|
-
* using a provided callback function and returning a setup structure for further transformations.
|
|
396
|
-
*
|
|
397
|
-
* @template T - The type of the input value that the transformation operates on.
|
|
398
|
-
*
|
|
399
|
-
* @typedef {Object} ITransform
|
|
400
|
-
*
|
|
401
|
-
* @property {function} then - Method that takes a callback function and returns a setup structure for further transformations.
|
|
402
|
-
* @param {ICallback<T>} condition - The transformation logic applied to the input.
|
|
403
|
-
* @returns {ISetup<K>} A setup structure for additional transformations.
|
|
404
|
-
*/
|
|
405
88
|
export type ITransform<T> = {
|
|
406
89
|
then<K>(condition: ICallback<T>): ISetup<K>;
|
|
407
90
|
};
|
|
408
|
-
/**
|
|
409
|
-
* ISerialisation interface defines the structure for objects responsible for
|
|
410
|
-
* handling the serialization and deserialization of data.
|
|
411
|
-
*
|
|
412
|
-
* This interface provides methods to serialize data into a specific format
|
|
413
|
-
* and to deserialize data back into a desired type.
|
|
414
|
-
*
|
|
415
|
-
* The generic method `deserialize` allows flexibility in defining the type
|
|
416
|
-
* of data to be returned upon deserialization.
|
|
417
|
-
*/
|
|
418
91
|
export type ISerialisation = {
|
|
419
92
|
serialize(): ISetup<string>;
|
|
420
93
|
deserialize<K>(): ISetup<K>;
|
|
421
94
|
};
|
|
422
|
-
/**
|
|
423
|
-
* A type that represents an ordered operation which processes and refines
|
|
424
|
-
* elements for a positive outcome. This is achieved through the use of
|
|
425
|
-
* conditional callbacks and the ability to chain multiple refinement conditions.
|
|
426
|
-
*
|
|
427
|
-
* @template T - The type of the element being processed.
|
|
428
|
-
*
|
|
429
|
-
* @property {Function} refine - Refines the current state based on a provided condition.
|
|
430
|
-
* This function accepts a single callback condition which determines the refinement logic
|
|
431
|
-
* and returns an updated setup instance.
|
|
432
|
-
*
|
|
433
|
-
* @property {Function} pushRefiners - Allows the addition of multiple refinement conditions
|
|
434
|
-
* to the current state. Accepts an array of callback conditions and returns an updated setup instance.
|
|
435
|
-
*/
|
|
436
95
|
export type IOrderedEmitByPositive<T> = {
|
|
437
96
|
refine(condition: ICallback<any>): ISetup<T>;
|
|
438
97
|
pushRefiners(conditions: ICallback<any>[]): ISetup<T>;
|
|
439
98
|
};
|
|
440
|
-
/**
|
|
441
|
-
* Represents an interface for an ordered transformation sequence applied to a data type `T`.
|
|
442
|
-
*
|
|
443
|
-
* @template T - The type of the data to be transformed.
|
|
444
|
-
*/
|
|
445
99
|
export type IOrderedTransform<T> = {
|
|
446
100
|
then<K>(condition: ICallback<T>): ISetup<K>;
|
|
447
101
|
};
|
|
448
|
-
/**
|
|
449
|
-
* Represents an interface for ordered serialization and deserialization operations.
|
|
450
|
-
* Useful for implementing structured serialization mechanisms that maintain a specific order.
|
|
451
|
-
*
|
|
452
|
-
* @interface
|
|
453
|
-
* @typedef {Object} IOrderedSerialisation
|
|
454
|
-
*
|
|
455
|
-
* @property {function(): ISetup<string>} serialize - Serializes an object or value into a string in a structured and ordered format.
|
|
456
|
-
* @property {function(): ISetup<K>} deserialize - Deserializes a structured and ordered string back into an object or value of type `K`.
|
|
457
|
-
*/
|
|
458
102
|
export type IOrderedSerialisation = {
|
|
459
103
|
serialize(): ISetup<string>;
|
|
460
104
|
deserialize<K>(): ISetup<K>;
|
|
461
105
|
};
|
|
462
|
-
/**
|
|
463
|
-
* Defines a structure for an object that provides a mechanism to emit a match based on a given condition.
|
|
464
|
-
*
|
|
465
|
-
* @template T The type parameter representing the expected return type of the setup process.
|
|
466
|
-
*/
|
|
467
106
|
export type IEmitMatchCondition<T> = {
|
|
468
107
|
emitMatch(condition: ICallback<any>): ISetup<T>;
|
|
469
108
|
};
|
|
470
|
-
/**
|
|
471
|
-
* Represents a condition for emitting a match in a specific order.
|
|
472
|
-
* The match condition is defined by the provided callback and
|
|
473
|
-
* can be used to set up ordered operations.
|
|
474
|
-
*
|
|
475
|
-
* @template T - The type of data associated with the ordered setup.
|
|
476
|
-
*
|
|
477
|
-
* @property {function(condition: ICallback<any>): IOrderedSetup<T>} emitMatch
|
|
478
|
-
* - A method to define a condition for emitting a match. It accepts a callback and returns an ordered setup configuration.
|
|
479
|
-
*/
|
|
480
109
|
export type IOrderedEmitMatchCondition<T> = {
|
|
481
110
|
emitMatch(condition: ICallback<any>): IOrderedSetup<T>;
|
|
482
111
|
};
|
|
483
|
-
/**
|
|
484
|
-
* ICollector is an interface that combines IDestroy and ISubscribeCounter interfaces,
|
|
485
|
-
* providing additional functionality for managing subscriptions.
|
|
486
|
-
* This interface allows for collecting, unsubscribing, and batch unsubscription of subscription-like objects.
|
|
487
|
-
*
|
|
488
|
-
* The primary purpose of ICollector is to manage subscription lifecycles efficiently and ensure
|
|
489
|
-
* that subscriptions are correctly unsubscribed when no longer needed.
|
|
490
|
-
*
|
|
491
|
-
* Methods:
|
|
492
|
-
* - collect(...subscriptionLikeList): Adds one or more subscription-like objects to be managed by the collector.
|
|
493
|
-
* - unsubscribe(subscriptionLike): Unsubscribes a single subscription-like object that the collector is managing.
|
|
494
|
-
* - unsubscribeAll(): Unsubscribes all subscription-like objects managed by the collector.
|
|
495
|
-
*/
|
|
496
112
|
export type ICollector = IDestroy & ISubscribeCounter & {
|
|
497
113
|
collect(...subscriptionLikeList: ISubscriptionLike[]): void;
|
|
498
114
|
unsubscribe(subscriptionLike: ISubscriptionLike): void;
|
|
499
115
|
unsubscribeAll(): void;
|
|
500
116
|
};
|
|
501
|
-
/**
|
|
502
|
-
* IOrderedObservable is a type definition that represents an object with the ability
|
|
503
|
-
* to determine whether elements are sorted in a specific order.
|
|
504
|
-
*
|
|
505
|
-
* This type contains a single method, `sortByOrder`, which is used to perform a determination
|
|
506
|
-
* or operation associated with the ordering of elements.
|
|
507
|
-
*
|
|
508
|
-
* @typedef {Object} IOrderedObservable
|
|
509
|
-
* @property {Function} sortByOrder - A method that checks or enforces the ordering of elements.
|
|
510
|
-
* Returns a boolean representing whether the ordering is correct or applicable.
|
|
511
|
-
*/
|
|
512
117
|
export type IOrderedObservable = {
|
|
513
118
|
sortByOrder(): boolean;
|
|
514
119
|
};
|
|
515
|
-
/**
|
|
516
|
-
* Represents a type that combines the behavior of an observer, an ordered observable, and an ordered observable pipe.
|
|
517
|
-
* This interface is generic and accepts a type parameter `T`, which specifies the data type it operates on.
|
|
518
|
-
*
|
|
519
|
-
* The `IOrdered` interface is composed of:
|
|
520
|
-
* - `IObserver<T>`: Handles observation logic for receiving values of type `T`.
|
|
521
|
-
* - `IOrderedObservable`: Encapsulates logic for ordered observables.
|
|
522
|
-
* - `IOrderedObservablePipe<T>`: Defines transformation and handling of ordered observable data of type `T`.
|
|
523
|
-
*
|
|
524
|
-
* Use this interface when working with structures that need ordered observation and transformation capabilities.
|
|
525
|
-
*/
|
|
526
120
|
export type IOrdered<T> = IObserver<T> & IOrderedObservable & IOrderedObservablePipe<T>;
|
|
527
|
-
/**
|
|
528
|
-
* A type that combines the features of `ISubscriptionLike` and `IOrder`.
|
|
529
|
-
* Represents a subscription-like object that also implements ordering properties or methods.
|
|
530
|
-
*
|
|
531
|
-
* This type is typically used in scenarios where an object needs to maintain
|
|
532
|
-
* subscription behavior alongside ordered data or operations.
|
|
533
|
-
*
|
|
534
|
-
* It inherits all the characteristics and requirements of both `ISubscriptionLike` and `IOrder`.
|
|
535
|
-
*/
|
|
536
121
|
export type IOrderedSubscriptionLike = (ISubscriptionLike & IOrder);
|
|
537
|
-
/**
|
|
538
|
-
* Represents an interface for an ordered subscription mechanism.
|
|
539
|
-
*
|
|
540
|
-
* @template T The type of data that the subscription will handle.
|
|
541
|
-
*
|
|
542
|
-
* @typedef {Object} IOrderedSubscribe
|
|
543
|
-
* @property {function(IListener<T>, IErrorCallback=): IOrderedSubscriptionLike} subscribe
|
|
544
|
-
* Subscribes to the updates with a listener callback and an optional error handler.
|
|
545
|
-
* Returns a subscription-like object for managing the subscription.
|
|
546
|
-
*
|
|
547
|
-
* @callback IListener
|
|
548
|
-
* Defines a listener callback function that is notified with updates of type T.
|
|
549
|
-
*
|
|
550
|
-
* @callback IErrorCallback
|
|
551
|
-
* Defines an optional error handler that is called whenever an error occurs in the subscription mechanism.
|
|
552
|
-
*
|
|
553
|
-
* @typedef {Object} IOrderedSubscriptionLike
|
|
554
|
-
* Represents an object that provides methods to manage the lifecycle of the subscription.
|
|
555
|
-
*/
|
|
556
122
|
export type IOrderedSubscribe<T> = {
|
|
557
123
|
subscribe(listener: IListener<T>, errorHandler?: IErrorCallback): IOrderedSubscriptionLike;
|
|
558
124
|
};
|
|
559
|
-
/**
|
|
560
|
-
* Represents a container for a chain of elements.
|
|
561
|
-
*
|
|
562
|
-
* This interface defines a structure that holds an array of elements.
|
|
563
|
-
* It is used to manage and interact with a sequential chain of items.
|
|
564
|
-
*
|
|
565
|
-
* Properties:
|
|
566
|
-
* - chain: An array representing the chain, where each element can be of any type.
|
|
567
|
-
*/
|
|
568
125
|
export type IChainContainer = {
|
|
569
126
|
chain: any[];
|
|
570
127
|
};
|
|
571
|
-
/**
|
|
572
|
-
* Represents the payload structure used within a pipe system.
|
|
573
|
-
*
|
|
574
|
-
* This type defines the fields necessary for managing the flow and control
|
|
575
|
-
* within a pipe operation, including breaking, unsubscribing, availability
|
|
576
|
-
* status, and the actual payload to be processed or transmitted.
|
|
577
|
-
*
|
|
578
|
-
* Properties:
|
|
579
|
-
* - isBreak: A boolean indicating if the pipe operation should terminate.
|
|
580
|
-
* - isUnsubscribe: A boolean indicating if the operation should include an unsubscribing action.
|
|
581
|
-
* - isAvailable: A boolean specifying whether the payload is available for processing.
|
|
582
|
-
* - payload: A flexible property designed to hold any data intended to be carried through the pipe.
|
|
583
|
-
*/
|
|
584
128
|
export type IPipePayload = {
|
|
585
129
|
isBreak: boolean;
|
|
586
130
|
isUnsubscribe: boolean;
|
|
587
131
|
isAvailable: boolean;
|
|
588
132
|
payload: any;
|
|
589
133
|
};
|
|
590
|
-
/**
|
|
591
|
-
* Represents a callback function interface for handling chain-related operations.
|
|
592
|
-
* This function is typically invoked with a payload to perform specific operations
|
|
593
|
-
* in a chain or pipeline.
|
|
594
|
-
*
|
|
595
|
-
* @callback IChainCallback
|
|
596
|
-
* @param {IPipePayload} data - The payload passed to the callback function
|
|
597
|
-
* containing the necessary data for processing.
|
|
598
|
-
*/
|
|
599
134
|
export type IChainCallback = (data: IPipePayload) => void;
|
|
600
|
-
/**
|
|
601
|
-
* Represents a pipeline case that extends the functionality of subscribing
|
|
602
|
-
* to a stream of data with additional case-checking operations.
|
|
603
|
-
*
|
|
604
|
-
* @template T - The type of data being processed in the pipeline.
|
|
605
|
-
* @extends ISubscribe<T>
|
|
606
|
-
*/
|
|
607
135
|
export type IPipeCase<T> = ISubscribe<T> & {
|
|
608
136
|
case(condition: ICallback<any>): IPipeCase<T> & ISubscribe<T>;
|
|
609
137
|
pushCases(conditions: ICallback<any>[]): IPipeCase<T> & ISubscribe<T>;
|
|
610
138
|
};
|
|
611
|
-
/**
|
|
612
|
-
* Represents a combined subscriber that can either be a listener or a setter for observable values.
|
|
613
|
-
*
|
|
614
|
-
* This type is a union of `IListener<T>` and `ISetObservableValue`, providing flexibility to handle subscriptions
|
|
615
|
-
* with different behaviors. It allows implementing components to react to changes in data or directly set observable values.
|
|
616
|
-
*
|
|
617
|
-
* @template T - The type of the value to be handled by the subscriber.
|
|
618
|
-
*/
|
|
619
139
|
export type ICombinedSubscriber<T> = IListener<T> | ISetObservableValue;
|
|
620
|
-
/**
|
|
621
|
-
* Represents a type definition for a group of subscriptions.
|
|
622
|
-
*
|
|
623
|
-
* This type can be either a single `ICombinedSubscriber` instance or an array of `ICombinedSubscriber` instances.
|
|
624
|
-
*
|
|
625
|
-
* @template T The type of data that the subscriber(s) will handle.
|
|
626
|
-
*/
|
|
627
140
|
export type ISubscribeGroup<T> = ICombinedSubscriber<T> | ICombinedSubscriber<T>[];
|
|
628
|
-
/**
|
|
629
|
-
* Represents an interface for adding a filter to a specific setup or configuration.
|
|
630
|
-
*
|
|
631
|
-
* @template T - The type that the filter setup operates on.
|
|
632
|
-
*/
|
|
633
141
|
export type IAddFilter<T> = {
|
|
634
142
|
addFilter(): IFilterSetup<T>;
|
|
635
143
|
};
|
|
636
|
-
/**
|
|
637
|
-
* Represents a setup for filtering that combines the functionality of IFilter and IFilterSwitch interfaces.
|
|
638
|
-
* This type is parameterized with a generic type T, which determines the type of data it operates on.
|
|
639
|
-
*
|
|
640
|
-
* It encompasses the capabilities provided by the IFilter and IFilterSwitch types, allowing for more
|
|
641
|
-
* robust and flexible filter setups. This is particularly useful in scenarios where both filtering
|
|
642
|
-
* logic and the ability to switch between filter states are required.
|
|
643
|
-
*
|
|
644
|
-
* @template T The type of the items to be filtered by the setup.
|
|
645
|
-
*/
|
|
646
144
|
export type IFilterSetup<T> = IFilter<T> & IFilterSwitch<T>;
|
|
647
|
-
/**
|
|
648
|
-
* Represents a generic filtering interface that applies conditions to a data set.
|
|
649
|
-
*
|
|
650
|
-
* @template T The type of data this filter will operate on.
|
|
651
|
-
*
|
|
652
|
-
* @typedef {Object} IFilter
|
|
653
|
-
*
|
|
654
|
-
* @property {function(condition: ICallback<any>): IFilterSetup<T>} filter
|
|
655
|
-
* Applies a single filtering condition to the data set.
|
|
656
|
-
*
|
|
657
|
-
* @property {function(conditions: ICallback<any>[]): IFilterSetup<T>} pushFilters
|
|
658
|
-
* Applies multiple filtering conditions to the data set in bulk.
|
|
659
|
-
*/
|
|
660
145
|
export type IFilter<T> = {
|
|
661
146
|
filter(condition: ICallback<any>): IFilterSetup<T>;
|
|
662
147
|
pushFilters(conditions: ICallback<any>[]): IFilterSetup<T>;
|
|
663
148
|
};
|
|
664
|
-
/**
|
|
665
|
-
* Interface representing a filter switch mechanism.
|
|
666
|
-
*
|
|
667
|
-
* This interface defines a method for managing cases within a filter switch
|
|
668
|
-
* process, allowing the user to determine a specific behavior based on a given
|
|
669
|
-
* context or condition mapped to the type parameter `T`.
|
|
670
|
-
*
|
|
671
|
-
* @template T Type of the context or condition used by the filter switch.
|
|
672
|
-
*/
|
|
673
149
|
export type IFilterSwitch<T> = {
|
|
674
150
|
switch(): FilterSwitchCase<T>;
|
|
675
151
|
};
|
|
676
|
-
/**
|
|
677
|
-
* Represents a filtering construct that allows chaining of conditional cases.
|
|
678
|
-
* Utilized to sequentially apply multiple conditions for filtering items.
|
|
679
|
-
*
|
|
680
|
-
* @template T - The type of the elements to be filtered.
|
|
681
|
-
*/
|
|
682
152
|
export type IFilterCase<T> = {
|
|
683
153
|
case(condition: ICallback<any>): IFilterCase<T>;
|
|
684
154
|
pushCases(conditions: ICallback<any>[]): IFilterCase<T>;
|
|
685
155
|
};
|
|
686
|
-
/**
|
|
687
|
-
* Represents the structure of a filter payload that includes the state of a break, availability, and additional payload.
|
|
688
|
-
*
|
|
689
|
-
* @typedef {Object} IFilterPayload
|
|
690
|
-
* @property {boolean} isBreak Indicates whether the current state represents a break.
|
|
691
|
-
* @property {boolean} isAvailable Indicates whether the current state is available.
|
|
692
|
-
* @property {any} payload Holds additional data associated with the filter payload.
|
|
693
|
-
*/
|
|
694
156
|
export type IFilterPayload = {
|
|
695
157
|
isBreak: boolean;
|
|
696
158
|
isAvailable: boolean;
|
|
697
159
|
payload: any;
|
|
698
160
|
};
|
|
699
|
-
/**
|
|
700
|
-
* Represents a callback function that is invoked during a filter chain operation.
|
|
701
|
-
*
|
|
702
|
-
* The IFilterChainCallback is intended to process or manipulate the provided
|
|
703
|
-
* filter payload and perform necessary actions as part of the filter chain execution.
|
|
704
|
-
*
|
|
705
|
-
* The callback function receives a single argument, which is the filter payload data,
|
|
706
|
-
* allowing it to perform operations relevant to the filtering process.
|
|
707
|
-
*
|
|
708
|
-
* @callback IFilterChainCallback
|
|
709
|
-
* @param {IFilterPayload} data - The payload data to be processed by the callback during the filter chain execution.
|
|
710
|
-
*/
|
|
711
161
|
export type IFilterChainCallback = (data: IFilterPayload) => void;
|
|
712
|
-
/**
|
|
713
|
-
* Represents the response format for a filtering operation.
|
|
714
|
-
*
|
|
715
|
-
* This type defines the standard structure for the response data when
|
|
716
|
-
* performing a filter operation. It indicates the success status and
|
|
717
|
-
* contains the corresponding payload of data.
|
|
718
|
-
*
|
|
719
|
-
* Properties:
|
|
720
|
-
* - `isOK`: A boolean indicating whether the filtering operation was successful.
|
|
721
|
-
* - `payload`: The data retrieved or processed during the filtering operation;
|
|
722
|
-
* this can be of any type.
|
|
723
|
-
*/
|
|
724
162
|
export type IFilterResponse = {
|
|
725
163
|
isOK: boolean;
|
|
726
164
|
payload: any;
|