evg_observable 2.15.1 → 2.15.3

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.
@@ -1,27 +1,6 @@
1
1
  import { IAddFilter, IErrorCallback, IFilterSetup, IObserver, ISetup, IStream, ISubscribeGroup, ISubscribeObject, ISubscriptionLike } from "./Types";
2
2
  import { SubscribeObject } from "./SubscribeObject";
3
3
  import { FilterCollection } from "./FilterCollection";
4
- /**
5
- * Observable is a generic class that represents an entity capable of emitting values
6
- * over time to subscribers. It provides mechanisms for managing subscribers and controlling
7
- * the flow of emitted data through filters and utility functions.
8
- *
9
- * @template T The type of the data managed by the Observable.
10
- *
11
- * Implements:
12
- * - IObserver<T>: For observing value changes.
13
- * - IStream<T>: For emitting streams of values.
14
- * - IAddFilter<T>: For adding and managing filters in the value processing.
15
- *
16
- * The Observable class provides the following key features:
17
- *
18
- * - Allows subscribers to listen for emitted values.
19
- * - Provides methods for enabling/disabling value emissions.
20
- * - Supports applying filters to process or validate values before emission.
21
- * - Allows streaming multiple values sequentially.
22
- * - Supports safe termination of resources through unsubscription and destruction.
23
- * - Handles asynchronous cleanup when active operations are in progress.
24
- */
25
4
  export declare class Observable<T> implements IObserver<T>, IStream<T>, IAddFilter<T> {
26
5
  protected subs: ISubscribeObject<T>[];
27
6
  protected enabled: boolean;
@@ -31,130 +10,21 @@ export declare class Observable<T> implements IObserver<T>, IStream<T>, IAddFilt
31
10
  protected filters: FilterCollection<T>;
32
11
  protected _value: T;
33
12
  constructor(value: T);
34
- /**
35
- * Adds an error handler filter to the current filter setup.
36
- *
37
- * @param {IErrorCallback} [errorHandler] - An optional error handler callback to handle errors in the filter.
38
- * @return {IFilterSetup<T>} The updated filter setup object with the specified error handler added.
39
- */
40
13
  addFilter(errorHandler?: IErrorCallback): IFilterSetup<T>;
41
- /**
42
- * Disables the current instance or functionality associated with this method.
43
- * Updates the internal state to reflect that it is no longer active or enabled.
44
- *
45
- * @return {void} This method does not return a value.
46
- */
47
14
  disable(): void;
48
- /**
49
- * Enables the current feature or functionality by setting its state to active.
50
- * Updates the internal state to indicate that it is enabled.
51
- *
52
- * @return {void} No return value.
53
- */
54
15
  enable(): void;
55
- /**
56
- * Indicates whether the current object or feature is enabled.
57
- *
58
- * @return {boolean} Returns true if enabled, otherwise false.
59
- */
60
16
  get isEnable(): boolean;
61
- /**
62
- * Processes the given value and sends it to all subscribers, respecting the enabled status, filters, and processing state.
63
- *
64
- * @param {T} value - The value to be processed and passed to subscribers.
65
- * @return {void} This method does not return a value.
66
- */
67
17
  next(value: T): void;
68
- /**
69
- * Processes an array of values and triggers the next method for each value if the stream
70
- * is not killed or disabled.
71
- *
72
- * @param {T[]} values - An array of values to be processed by the stream.
73
- * @return {void} This method does not return a value.
74
- */
75
18
  stream(values: T[]): void;
76
- /**
77
- * Clears all items in the `trash` array by unsubscribing each item and resetting the array length to zero.
78
- *
79
- * @return {void} No return value.
80
- */
81
19
  private clearTrash;
82
- /**
83
- * Unsubscribes the provided listener by removing it from the subscribers' list
84
- * or marking it for cleanup if the process is currently active.
85
- *
86
- * @param {ISubscriptionLike} listener - The subscription listener to be unsubscribed.
87
- * @return {void} No return value.
88
- */
89
20
  unSubscribe(listener: ISubscriptionLike): void;
90
- /**
91
- * Cleans up resources and terminates any ongoing processes or subscriptions associated with the instance.
92
- *
93
- * Sets the internal state to indicate it has been destroyed. If a process is associated, waits until the process is no longer active
94
- * before clearing internal data and subscriptions.
95
- *
96
- * @return {void} Does not return any value.
97
- */
98
21
  destroy(): void;
99
- /**
100
- * Unsubscribes from all active subscriptions by clearing the subscriptions list.
101
- * Prevents further operations if the instance has already been marked as killed.
102
- * Safe to call during next() - uses deferred cleanup mechanism.
103
- *
104
- * @return {void} Does not return a value.
105
- */
106
22
  unsubscribeAll(): void;
107
- /**
108
- * Retrieves the current value if the instance is active.
109
- * If the instance is marked as killed, undefined is returned.
110
- *
111
- * @return {T | undefined} The current value or undefined if the instance is killed.
112
- */
113
23
  getValue(): T | undefined;
114
- /**
115
- * Calculates and returns the size based on the current state.
116
- *
117
- * @return {number} The size, which is the number of subscriptions if not killed; otherwise, 0.
118
- */
119
24
  size(): number;
120
- /**
121
- * Subscribes an observer to this instance, monitoring its changes and handling errors if any.
122
- *
123
- * @param observer The observer object that implements the ISubscribeGroup interface which will be subscribed.
124
- * @param errorHandler Optional callback function to handle errors encountered during the subscription process.
125
- * @return An object implementing the ISubscriptionLike interface that represents the subscription,
126
- * or undefined if the subscription is not successful.
127
- */
128
25
  subscribe(observer: ISubscribeGroup<T>, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
129
- /**
130
- * Adds an observer to the subscribe object and associates it with a potential error handler.
131
- * The subscribe object is added to the list of subscriptions for tracking purposes.
132
- *
133
- * @param {SubscribeObject<T>} subscribeObject - The object that manages the subscription to observers.
134
- * @param {ISubscribeGroup<T>} observer - The observer to be subscribed to the subscribe object.
135
- * @param {IErrorCallback} [errorHandler] - Optional error handler callback to handle errors during subscription.
136
- * @return {void} This method does not return a value.
137
- */
138
26
  protected addObserver(subscribeObject: SubscribeObject<T>, observer: ISubscribeGroup<T>, errorHandler?: IErrorCallback): void;
139
- /**
140
- * Determines if the provided object is a valid listener.
141
- *
142
- * @param listener An instance of ISubscribeGroup of type T to validate as a listener.
143
- * @return Returns true if the provided listener is valid and the object is not marked as killed; otherwise, returns false.
144
- */
145
27
  protected isListener(listener: ISubscribeGroup<T>): boolean;
146
- /**
147
- * Handles the creation and management of a SubscribeObject if the current instance is active.
148
- * It returns an `ISetup<T>` object to allow additional configurations or operations.
149
- * If the instance is in a "killed" state, it will not proceed and returns undefined.
150
- *
151
- * @return {ISetup<T> | undefined} The created SubscribeObject wrapped in an ISetup<T> interface if the instance is active, otherwise undefined.
152
- */
153
28
  pipe(): ISetup<T> | undefined;
154
- /**
155
- * Determines if the object has been destroyed.
156
- *
157
- * @return {boolean} True if the object is destroyed, false otherwise.
158
- */
159
29
  get isDestroyed(): boolean;
160
30
  }
@@ -4,27 +4,6 @@ exports.Observable = void 0;
4
4
  const FunctionLibs_1 = require("./FunctionLibs");
5
5
  const SubscribeObject_1 = require("./SubscribeObject");
6
6
  const FilterCollection_1 = require("./FilterCollection");
7
- /**
8
- * Observable is a generic class that represents an entity capable of emitting values
9
- * over time to subscribers. It provides mechanisms for managing subscribers and controlling
10
- * the flow of emitted data through filters and utility functions.
11
- *
12
- * @template T The type of the data managed by the Observable.
13
- *
14
- * Implements:
15
- * - IObserver<T>: For observing value changes.
16
- * - IStream<T>: For emitting streams of values.
17
- * - IAddFilter<T>: For adding and managing filters in the value processing.
18
- *
19
- * The Observable class provides the following key features:
20
- *
21
- * - Allows subscribers to listen for emitted values.
22
- * - Provides methods for enabling/disabling value emissions.
23
- * - Supports applying filters to process or validate values before emission.
24
- * - Allows streaming multiple values sequentially.
25
- * - Supports safe termination of resources through unsubscription and destruction.
26
- * - Handles asynchronous cleanup when active operations are in progress.
27
- */
28
7
  class Observable {
29
8
  subs = [];
30
9
  enabled = true;
@@ -36,49 +15,20 @@ class Observable {
36
15
  constructor(value) {
37
16
  this._value = value;
38
17
  }
39
- /**
40
- * Adds an error handler filter to the current filter setup.
41
- *
42
- * @param {IErrorCallback} [errorHandler] - An optional error handler callback to handle errors in the filter.
43
- * @return {IFilterSetup<T>} The updated filter setup object with the specified error handler added.
44
- */
45
18
  addFilter(errorHandler) {
46
19
  if (errorHandler)
47
20
  this.filters.addErrorHandler(errorHandler);
48
21
  return this.filters;
49
22
  }
50
- /**
51
- * Disables the current instance or functionality associated with this method.
52
- * Updates the internal state to reflect that it is no longer active or enabled.
53
- *
54
- * @return {void} This method does not return a value.
55
- */
56
23
  disable() {
57
24
  this.enabled = false;
58
25
  }
59
- /**
60
- * Enables the current feature or functionality by setting its state to active.
61
- * Updates the internal state to indicate that it is enabled.
62
- *
63
- * @return {void} No return value.
64
- */
65
26
  enable() {
66
27
  this.enabled = true;
67
28
  }
68
- /**
69
- * Indicates whether the current object or feature is enabled.
70
- *
71
- * @return {boolean} Returns true if enabled, otherwise false.
72
- */
73
29
  get isEnable() {
74
30
  return this.enabled;
75
31
  }
76
- /**
77
- * Processes the given value and sends it to all subscribers, respecting the enabled status, filters, and processing state.
78
- *
79
- * @param {T} value - The value to be processed and passed to subscribers.
80
- * @return {void} This method does not return a value.
81
- */
82
32
  next(value) {
83
33
  if (this.killed)
84
34
  return;
@@ -97,13 +47,6 @@ class Observable {
97
47
  this.process = false;
98
48
  this.trash.length && this.clearTrash();
99
49
  }
100
- /**
101
- * Processes an array of values and triggers the next method for each value if the stream
102
- * is not killed or disabled.
103
- *
104
- * @param {T[]} values - An array of values to be processed by the stream.
105
- * @return {void} This method does not return a value.
106
- */
107
50
  stream(values) {
108
51
  if (this.killed)
109
52
  return;
@@ -112,24 +55,12 @@ class Observable {
112
55
  for (let i = 0; i < values.length; i++)
113
56
  this.next(values[i]);
114
57
  }
115
- /**
116
- * Clears all items in the `trash` array by unsubscribing each item and resetting the array length to zero.
117
- *
118
- * @return {void} No return value.
119
- */
120
58
  clearTrash() {
121
59
  const length = this.trash.length;
122
60
  for (let i = 0; i < length; i++)
123
61
  this.unSubscribe(this.trash[i]);
124
62
  this.trash.length = 0;
125
63
  }
126
- /**
127
- * Unsubscribes the provided listener by removing it from the subscribers' list
128
- * or marking it for cleanup if the process is currently active.
129
- *
130
- * @param {ISubscriptionLike} listener - The subscription listener to be unsubscribed.
131
- * @return {void} No return value.
132
- */
133
64
  unSubscribe(listener) {
134
65
  if (this.killed)
135
66
  return;
@@ -139,14 +70,6 @@ class Observable {
139
70
  }
140
71
  this.subs && !(0, FunctionLibs_1.quickDeleteFromArray)(this.subs, listener);
141
72
  }
142
- /**
143
- * Cleans up resources and terminates any ongoing processes or subscriptions associated with the instance.
144
- *
145
- * Sets the internal state to indicate it has been destroyed. If a process is associated, waits until the process is no longer active
146
- * before clearing internal data and subscriptions.
147
- *
148
- * @return {void} Does not return any value.
149
- */
150
73
  destroy() {
151
74
  if (this.killed)
152
75
  return;
@@ -161,18 +84,10 @@ class Observable {
161
84
  this.subs.length = 0;
162
85
  });
163
86
  }
164
- /**
165
- * Unsubscribes from all active subscriptions by clearing the subscriptions list.
166
- * Prevents further operations if the instance has already been marked as killed.
167
- * Safe to call during next() - uses deferred cleanup mechanism.
168
- *
169
- * @return {void} Does not return a value.
170
- */
171
87
  unsubscribeAll() {
172
88
  if (this.killed)
173
89
  return;
174
90
  if (this.process) {
175
- // Defer removal until next() completes
176
91
  const subs = this.subs;
177
92
  for (let i = 0; i < subs.length; i++)
178
93
  this.trash.push(subs[i]);
@@ -180,35 +95,16 @@ class Observable {
180
95
  }
181
96
  this.subs.length = 0;
182
97
  }
183
- /**
184
- * Retrieves the current value if the instance is active.
185
- * If the instance is marked as killed, undefined is returned.
186
- *
187
- * @return {T | undefined} The current value or undefined if the instance is killed.
188
- */
189
98
  getValue() {
190
99
  if (this.killed)
191
100
  return undefined;
192
101
  return this._value;
193
102
  }
194
- /**
195
- * Calculates and returns the size based on the current state.
196
- *
197
- * @return {number} The size, which is the number of subscriptions if not killed; otherwise, 0.
198
- */
199
103
  size() {
200
104
  if (this.killed)
201
105
  return 0;
202
106
  return this.subs.length;
203
107
  }
204
- /**
205
- * Subscribes an observer to this instance, monitoring its changes and handling errors if any.
206
- *
207
- * @param observer The observer object that implements the ISubscribeGroup interface which will be subscribed.
208
- * @param errorHandler Optional callback function to handle errors encountered during the subscription process.
209
- * @return An object implementing the ISubscriptionLike interface that represents the subscription,
210
- * or undefined if the subscription is not successful.
211
- */
212
108
  subscribe(observer, errorHandler) {
213
109
  if (this.killed)
214
110
  return undefined;
@@ -218,37 +114,15 @@ class Observable {
218
114
  this.addObserver(subscribeObject, observer, errorHandler);
219
115
  return subscribeObject;
220
116
  }
221
- /**
222
- * Adds an observer to the subscribe object and associates it with a potential error handler.
223
- * The subscribe object is added to the list of subscriptions for tracking purposes.
224
- *
225
- * @param {SubscribeObject<T>} subscribeObject - The object that manages the subscription to observers.
226
- * @param {ISubscribeGroup<T>} observer - The observer to be subscribed to the subscribe object.
227
- * @param {IErrorCallback} [errorHandler] - Optional error handler callback to handle errors during subscription.
228
- * @return {void} This method does not return a value.
229
- */
230
117
  addObserver(subscribeObject, observer, errorHandler) {
231
118
  subscribeObject.subscribe(observer, errorHandler);
232
119
  this.subs.push(subscribeObject);
233
120
  }
234
- /**
235
- * Determines if the provided object is a valid listener.
236
- *
237
- * @param listener An instance of ISubscribeGroup of type T to validate as a listener.
238
- * @return Returns true if the provided listener is valid and the object is not marked as killed; otherwise, returns false.
239
- */
240
121
  isListener(listener) {
241
122
  if (this.killed)
242
123
  return false;
243
124
  return !!listener;
244
125
  }
245
- /**
246
- * Handles the creation and management of a SubscribeObject if the current instance is active.
247
- * It returns an `ISetup<T>` object to allow additional configurations or operations.
248
- * If the instance is in a "killed" state, it will not proceed and returns undefined.
249
- *
250
- * @return {ISetup<T> | undefined} The created SubscribeObject wrapped in an ISetup<T> interface if the instance is active, otherwise undefined.
251
- */
252
126
  pipe() {
253
127
  if (this.killed)
254
128
  return undefined;
@@ -256,11 +130,6 @@ class Observable {
256
130
  this.subs.push(subscribeObject);
257
131
  return subscribeObject;
258
132
  }
259
- /**
260
- * Determines if the object has been destroyed.
261
- *
262
- * @return {boolean} True if the object is destroyed, false otherwise.
263
- */
264
133
  get isDestroyed() {
265
134
  return this.killed;
266
135
  }
@@ -1,70 +1,11 @@
1
1
  import { Observable } from "./Observable";
2
2
  import { IErrorCallback, IOrdered, IOrderedSetup, IOrderedSubscriptionLike, ISubscribeGroup, ISubscriptionLike } from "./Types";
3
- /**
4
- * Represents an observable data structure that maintains elements in a specific order and provides
5
- * methods to manipulate and subscribe to its elements.
6
- *
7
- * The `OrderedObservable` class supports sorting elements in ascending or descending order and allows
8
- * for subscription to changes in its state. It extends the capabilities of a basic `Observable` by
9
- * incorporating sorting and ordered processing mechanisms.
10
- *
11
- * @template T The type of data stored and handled by the observable.
12
- * @extends Observable<T>
13
- * @implements IOrdered<T>
14
- */
15
3
  export declare class OrderedObservable<T> extends Observable<T> implements IOrdered<T> {
16
- /**
17
- * Represents the direction in which sorting should occur.
18
- * The value is expected to indicate whether the sorting
19
- * should be performed in ascending or descending order.
20
- *
21
- * Possible values:
22
- * - `sortAscending`: Sorting in ascending order.
23
- * - `sortDescending`: Sorting in descending order.
24
- */
25
4
  private sortDirection;
26
- /**
27
- * Sets the sorting order to ascending and applies the sorting.
28
- *
29
- * @return {boolean} Returns true if the sorting operation is successful, otherwise false.
30
- */
31
5
  setAscendingSort(): boolean;
32
- /**
33
- * Sets the sorting order to descending and updates the sort configuration.
34
- *
35
- * @return {boolean} Returns `true` if the sorting operation is configured and applied successfully, otherwise returns `false`.
36
- */
37
6
  setDescendingSort(): boolean;
38
- /**
39
- * Sorts the `subs` array based on the specified sort direction if the object is not in a "killed" state.
40
- *
41
- * @return {boolean} Returns true if the sorting was performed, false if the object is in a "killed" state.
42
- */
43
7
  sortByOrder(): boolean;
44
- /**
45
- * Subscribes a listener to this instance with an optional error handler.
46
- *
47
- * @param {ISubscribeGroup<T>} listener - The listener object that should be notified of changes.
48
- * @param {IErrorCallback} [errorHandler] - An optional handler to process errors during execution.
49
- * @return {IOrderedSubscriptionLike | undefined} Returns an instance of IOrderedSubscriptionLike if the listener is valid; otherwise, returns undefined.
50
- */
51
8
  subscribe(listener: ISubscribeGroup<T>, errorHandler?: IErrorCallback): IOrderedSubscriptionLike | undefined;
52
- /**
53
- * Creates and returns an instance of `OrderedSubscribeObject` tied to the current object,
54
- * facilitating ordered subscription setup. If the instance is marked as killed, it returns undefined.
55
- *
56
- * @return {IOrderedSetup<T> | undefined} An instance of `OrderedSubscribeObject` for subscription setup,
57
- * or undefined if the operation is not allowed.
58
- */
59
9
  pipe(): IOrderedSetup<T> | undefined;
60
- /**
61
- * Removes a previously subscribed listener from the subscription list,
62
- * preventing it from receiving further updates. If the system is in a
63
- * "killed" state or specific conditions in the process flow are met,
64
- * the listener may instead be added to a trash list.
65
- *
66
- * @param {ISubscriptionLike} listener - The subscription listener to be unsubscribed or handled accordingly.
67
- * @return {void} Does not return any value.
68
- */
69
10
  unSubscribe(listener: ISubscriptionLike): void;
70
11
  }
@@ -4,65 +4,22 @@ exports.OrderedObservable = void 0;
4
4
  const Observable_1 = require("./Observable");
5
5
  const FunctionLibs_1 = require("./FunctionLibs");
6
6
  const OrderedSubscribeObject_1 = require("./OrderedSubscribeObject");
7
- /**
8
- * Represents an observable data structure that maintains elements in a specific order and provides
9
- * methods to manipulate and subscribe to its elements.
10
- *
11
- * The `OrderedObservable` class supports sorting elements in ascending or descending order and allows
12
- * for subscription to changes in its state. It extends the capabilities of a basic `Observable` by
13
- * incorporating sorting and ordered processing mechanisms.
14
- *
15
- * @template T The type of data stored and handled by the observable.
16
- * @extends Observable<T>
17
- * @implements IOrdered<T>
18
- */
19
7
  class OrderedObservable extends Observable_1.Observable {
20
- /**
21
- * Represents the direction in which sorting should occur.
22
- * The value is expected to indicate whether the sorting
23
- * should be performed in ascending or descending order.
24
- *
25
- * Possible values:
26
- * - `sortAscending`: Sorting in ascending order.
27
- * - `sortDescending`: Sorting in descending order.
28
- */
29
8
  sortDirection = FunctionLibs_1.sortAscending;
30
- /**
31
- * Sets the sorting order to ascending and applies the sorting.
32
- *
33
- * @return {boolean} Returns true if the sorting operation is successful, otherwise false.
34
- */
35
9
  setAscendingSort() {
36
10
  this.sortDirection = FunctionLibs_1.sortAscending;
37
11
  return this.sortByOrder();
38
12
  }
39
- /**
40
- * Sets the sorting order to descending and updates the sort configuration.
41
- *
42
- * @return {boolean} Returns `true` if the sorting operation is configured and applied successfully, otherwise returns `false`.
43
- */
44
13
  setDescendingSort() {
45
14
  this.sortDirection = FunctionLibs_1.sortDescending;
46
15
  return this.sortByOrder();
47
16
  }
48
- /**
49
- * Sorts the `subs` array based on the specified sort direction if the object is not in a "killed" state.
50
- *
51
- * @return {boolean} Returns true if the sorting was performed, false if the object is in a "killed" state.
52
- */
53
17
  sortByOrder() {
54
18
  if (this.killed)
55
19
  return false;
56
20
  this.subs.sort(this.sortDirection);
57
21
  return true;
58
22
  }
59
- /**
60
- * Subscribes a listener to this instance with an optional error handler.
61
- *
62
- * @param {ISubscribeGroup<T>} listener - The listener object that should be notified of changes.
63
- * @param {IErrorCallback} [errorHandler] - An optional handler to process errors during execution.
64
- * @return {IOrderedSubscriptionLike | undefined} Returns an instance of IOrderedSubscriptionLike if the listener is valid; otherwise, returns undefined.
65
- */
66
23
  subscribe(listener, errorHandler) {
67
24
  if (!this.isListener(listener))
68
25
  return undefined;
@@ -70,13 +27,6 @@ class OrderedObservable extends Observable_1.Observable {
70
27
  this.addObserver(subscribeObject, listener, errorHandler);
71
28
  return subscribeObject;
72
29
  }
73
- /**
74
- * Creates and returns an instance of `OrderedSubscribeObject` tied to the current object,
75
- * facilitating ordered subscription setup. If the instance is marked as killed, it returns undefined.
76
- *
77
- * @return {IOrderedSetup<T> | undefined} An instance of `OrderedSubscribeObject` for subscription setup,
78
- * or undefined if the operation is not allowed.
79
- */
80
30
  pipe() {
81
31
  if (this.killed)
82
32
  return undefined;
@@ -84,15 +34,6 @@ class OrderedObservable extends Observable_1.Observable {
84
34
  this.subs.push(subscribeObject);
85
35
  return subscribeObject;
86
36
  }
87
- /**
88
- * Removes a previously subscribed listener from the subscription list,
89
- * preventing it from receiving further updates. If the system is in a
90
- * "killed" state or specific conditions in the process flow are met,
91
- * the listener may instead be added to a trash list.
92
- *
93
- * @param {ISubscriptionLike} listener - The subscription listener to be unsubscribed or handled accordingly.
94
- * @return {void} Does not return any value.
95
- */
96
37
  unSubscribe(listener) {
97
38
  if (this.killed)
98
39
  return;
@@ -1,53 +1,10 @@
1
1
  import { SubscribeObject } from "./SubscribeObject";
2
2
  import { IErrorCallback, IListener, IOrdered, IOrderedSetup, IOrderedSubscribe, IOrderedSubscriptionLike, ISetObservableValue } from "./Types";
3
3
  import { OrderedObservable } from "./OrderedObservable";
4
- /**
5
- * Represents an ordered subscription object, extending the functionality
6
- * of the SubscribeObject to include ordering and the ability to manage
7
- * subscriptions based on a given order.
8
- *
9
- * This class is designed to work with observables that support ordering
10
- * functionality. It implements the `IOrderedSetup` interface to manage
11
- * ordering behavior and sorting operations.
12
- *
13
- * @template T The type of the data managed by the subscription.
14
- */
15
4
  export declare class OrderedSubscribeObject<T> extends SubscribeObject<T> implements IOrderedSetup<T> {
16
- /**
17
- * Creates an instance of the constructor with the specified observable and pipe flag.
18
- *
19
- * @param {OrderedObservable<T> | IOrdered<T>} observable - The ordered observable or IOrdered instance to attach to this instance.
20
- * @param {boolean} [isPipe] - Optional flag indicating if the stream is part of a piping sequence.
21
- * @return {void}
22
- */
23
5
  constructor(observable: OrderedObservable<T> | IOrdered<T>, isPipe?: boolean);
24
- /**
25
- * Retrieves the order value.
26
- *
27
- * @return {number} The current order value.
28
- */
29
6
  get order(): number;
30
- /**
31
- * Sets the order value for this object. If the observer is not defined or is destroyed,
32
- * the order value is reset to undefined. Otherwise, the order value is updated, and
33
- * the observer is instructed to sort items by the updated order.
34
- *
35
- * @param {number} value - The new order value to be set.
36
- */
37
7
  set order(value: number);
38
- /**
39
- * Subscribes an observer to the observable, allowing it to receive updates.
40
- *
41
- * @param {IListener<T> | ISetObservableValue} observer - The observer that will receive updates. It can be either a listener function or a setter for the observable value.
42
- * @param {IErrorCallback} [errorHandler] - An optional error callback that will be invoked if an error occurs during the subscription process.
43
- * @return {IOrderedSubscriptionLike} The current subscription instance for chaining purposes.
44
- */
45
8
  subscribe(observer: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): IOrderedSubscriptionLike;
46
- /**
47
- * Sets the subscription to be invoked only once. After the subscription
48
- * is called for the first time, it will be automatically removed.
49
- *
50
- * @return {IOrderedSubscribe<T>} The subscription instance configured to execute only once.
51
- */
52
9
  setOnce(): IOrderedSubscribe<T>;
53
10
  }
@@ -2,43 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderedSubscribeObject = void 0;
4
4
  const SubscribeObject_1 = require("./SubscribeObject");
5
- /**
6
- * Represents an ordered subscription object, extending the functionality
7
- * of the SubscribeObject to include ordering and the ability to manage
8
- * subscriptions based on a given order.
9
- *
10
- * This class is designed to work with observables that support ordering
11
- * functionality. It implements the `IOrderedSetup` interface to manage
12
- * ordering behavior and sorting operations.
13
- *
14
- * @template T The type of the data managed by the subscription.
15
- */
16
5
  class OrderedSubscribeObject extends SubscribeObject_1.SubscribeObject {
17
- /**
18
- * Creates an instance of the constructor with the specified observable and pipe flag.
19
- *
20
- * @param {OrderedObservable<T> | IOrdered<T>} observable - The ordered observable or IOrdered instance to attach to this instance.
21
- * @param {boolean} [isPipe] - Optional flag indicating if the stream is part of a piping sequence.
22
- * @return {void}
23
- */
24
6
  constructor(observable, isPipe) {
25
7
  super(observable, isPipe);
26
8
  }
27
- /**
28
- * Retrieves the order value.
29
- *
30
- * @return {number} The current order value.
31
- */
32
9
  get order() {
33
10
  return this._order;
34
11
  }
35
- /**
36
- * Sets the order value for this object. If the observer is not defined or is destroyed,
37
- * the order value is reset to undefined. Otherwise, the order value is updated, and
38
- * the observer is instructed to sort items by the updated order.
39
- *
40
- * @param {number} value - The new order value to be set.
41
- */
42
12
  set order(value) {
43
13
  if (!this.observer ||
44
14
  (this.observer && this.observer.isDestroyed)) {
@@ -48,23 +18,10 @@ class OrderedSubscribeObject extends SubscribeObject_1.SubscribeObject {
48
18
  this._order = value;
49
19
  this.observer.sortByOrder();
50
20
  }
51
- /**
52
- * Subscribes an observer to the observable, allowing it to receive updates.
53
- *
54
- * @param {IListener<T> | ISetObservableValue} observer - The observer that will receive updates. It can be either a listener function or a setter for the observable value.
55
- * @param {IErrorCallback} [errorHandler] - An optional error callback that will be invoked if an error occurs during the subscription process.
56
- * @return {IOrderedSubscriptionLike} The current subscription instance for chaining purposes.
57
- */
58
21
  subscribe(observer, errorHandler) {
59
22
  super.subscribe(observer, errorHandler);
60
23
  return this;
61
24
  }
62
- /**
63
- * Sets the subscription to be invoked only once. After the subscription
64
- * is called for the first time, it will be automatically removed.
65
- *
66
- * @return {IOrderedSubscribe<T>} The subscription instance configured to execute only once.
67
- */
68
25
  setOnce() {
69
26
  return super.setOnce();
70
27
  }