evg_observable 2.14.61 → 2.15.1

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,6 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getListener = exports.quickDeleteFromArray = exports.deleteFromArray = exports.sortDescending = exports.sortAscending = void 0;
3
+ exports.sortAscending = sortAscending;
4
+ exports.sortDescending = sortDescending;
5
+ exports.deleteFromArray = deleteFromArray;
6
+ exports.quickDeleteFromArray = quickDeleteFromArray;
7
+ exports.getListener = getListener;
8
+ /**
9
+ * Compares two ISubscribeObject items based on their `order` property
10
+ * and sorts them in ascending order.
11
+ *
12
+ * @param {ISubscribeObject<any>} a - The first object to compare.
13
+ * @param {ISubscribeObject<any>} b - The second object to compare.
14
+ * @return {number} - Returns 1 if the `order` property of `a` is greater than `b`,
15
+ * -1 if the `order` property of `a` is less than `b`,
16
+ * or 0 if they are equal.
17
+ */
4
18
  function sortAscending(a, b) {
5
19
  if (a.order > b.order)
6
20
  return 1;
@@ -8,7 +22,13 @@ function sortAscending(a, b) {
8
22
  return -1;
9
23
  return 0;
10
24
  }
11
- exports.sortAscending = sortAscending;
25
+ /**
26
+ * Compares two objects based on their `order` property for descending sorting.
27
+ *
28
+ * @param {ISubscribeObject<any>} a - The first object to compare, expected to have an `order` property.
29
+ * @param {ISubscribeObject<any>} b - The second object to compare, expected to have an `order` property.
30
+ * @return {number} - Returns -1 if `a.order` is greater than `b.order`, 1 if `a.order` is less than `b.order`, and 0 if they are equal.
31
+ */
12
32
  function sortDescending(a, b) {
13
33
  if (a.order > b.order)
14
34
  return -1;
@@ -16,7 +36,13 @@ function sortDescending(a, b) {
16
36
  return 1;
17
37
  return 0;
18
38
  }
19
- exports.sortDescending = sortDescending;
39
+ /**
40
+ * Removes the specified component from the provided array if it exists.
41
+ *
42
+ * @param {T[]} arr - The array from which the component will be removed.
43
+ * @param {T} component - The component to be removed from the array.
44
+ * @return {boolean} Returns true if the component was successfully removed, false otherwise.
45
+ */
20
46
  function deleteFromArray(arr, component) {
21
47
  const index = arr.indexOf(component);
22
48
  if (index === -1)
@@ -24,29 +50,50 @@ function deleteFromArray(arr, component) {
24
50
  arr.splice(index, 1);
25
51
  return true;
26
52
  }
27
- exports.deleteFromArray = deleteFromArray;
53
+ /**
54
+ * Removes a specified element from an array by replacing it with the last element
55
+ * and reducing the array's length. This method avoids maintaining order but performs
56
+ * the deletion operation efficiently.
57
+ *
58
+ * @param {T[]} arr - The array from which the element will be removed.
59
+ * @param {T} component - The element to be removed from the array.
60
+ * @return {boolean} - Returns true if the element was found and removed;
61
+ * otherwise, returns false.
62
+ */
28
63
  function quickDeleteFromArray(arr, component) {
29
64
  const index = arr.indexOf(component);
30
65
  if (index === -1)
31
66
  return false;
32
67
  arr[index] = arr[arr.length - 1];
33
- arr.length = arr.length - 1;
68
+ arr.length--;
34
69
  return true;
35
70
  }
36
- exports.quickDeleteFromArray = quickDeleteFromArray;
37
- function getListener(listener) {
38
- if (Array.isArray(listener)) {
71
+ /**
72
+ * Returns a listener function based on the provided listener group.
73
+ *
74
+ * @param {ISubscribeGroup<T>} listenerGroup - The group of listener(s). It can be a single listener
75
+ * or an array of listeners that are invoked when the returned listener is called.
76
+ * @return {IListener<T>} A single listener function that wraps the provided listener or group of listeners
77
+ * and invokes them with the provided data.
78
+ */
79
+ function getListener(listenerGroup) {
80
+ if (Array.isArray(listenerGroup)) {
39
81
  const group = [];
40
- for (let i = 0; i < listener.length; i++)
41
- group.push(wrapListener(listener[i]));
82
+ for (let i = 0; i < listenerGroup.length; i++)
83
+ group.push(wrapListener(listenerGroup[i]));
42
84
  return (data) => {
43
85
  for (let i = 0; i < group.length; i++)
44
86
  group[i](data);
45
87
  };
46
88
  }
47
- return wrapListener(listener);
89
+ return wrapListener(listenerGroup);
48
90
  }
49
- exports.getListener = getListener;
91
+ /**
92
+ * Wraps the provided listener, ensuring it conforms to the IListener<T> interface.
93
+ *
94
+ * @param listener The listener to be wrapped. Can be either an IListener<T> or an ISetObservableValue.
95
+ * @return Returns a listener that adheres to the IListener<T> interface.
96
+ */
50
97
  function wrapListener(listener) {
51
98
  if ("next" in listener)
52
99
  return (value) => listener.next(value);
@@ -1,29 +1,160 @@
1
1
  import { IAddFilter, IErrorCallback, IFilterSetup, IObserver, ISetup, IStream, ISubscribeGroup, ISubscribeObject, ISubscriptionLike } from "./Types";
2
2
  import { SubscribeObject } from "./SubscribeObject";
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
+ */
3
25
  export declare class Observable<T> implements IObserver<T>, IStream<T>, IAddFilter<T> {
4
- private value;
5
26
  protected subs: ISubscribeObject<T>[];
6
- private enabled;
27
+ protected enabled: boolean;
7
28
  protected killed: boolean;
8
29
  protected process: boolean;
9
30
  protected trash: ISubscriptionLike[];
10
- private filters;
31
+ protected filters: FilterCollection<T>;
32
+ protected _value: T;
11
33
  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
+ */
12
40
  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
+ */
13
47
  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
+ */
14
54
  enable(): void;
55
+ /**
56
+ * Indicates whether the current object or feature is enabled.
57
+ *
58
+ * @return {boolean} Returns true if enabled, otherwise false.
59
+ */
15
60
  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
+ */
16
67
  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
+ */
17
75
  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
+ */
18
81
  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
+ */
19
89
  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
+ */
20
98
  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
+ */
21
106
  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
+ */
22
113
  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
+ */
23
119
  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
+ */
24
128
  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
+ */
25
138
  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
+ */
26
145
  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
+ */
27
153
  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
+ */
28
159
  get isDestroyed(): boolean;
29
160
  }
@@ -4,45 +4,106 @@ 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
+ */
7
28
  class Observable {
8
- value;
9
29
  subs = [];
10
30
  enabled = true;
11
31
  killed = false;
12
32
  process = false;
13
33
  trash = [];
14
34
  filters = new FilterCollection_1.FilterCollection();
35
+ _value;
15
36
  constructor(value) {
16
- this.value = value;
37
+ this._value = value;
17
38
  }
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
+ */
18
45
  addFilter(errorHandler) {
19
46
  if (errorHandler)
20
47
  this.filters.addErrorHandler(errorHandler);
21
48
  return this.filters;
22
49
  }
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
+ */
23
56
  disable() {
24
57
  this.enabled = false;
25
58
  }
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
+ */
26
65
  enable() {
27
66
  this.enabled = true;
28
67
  }
68
+ /**
69
+ * Indicates whether the current object or feature is enabled.
70
+ *
71
+ * @return {boolean} Returns true if enabled, otherwise false.
72
+ */
29
73
  get isEnable() {
30
74
  return this.enabled;
31
75
  }
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
+ */
32
82
  next(value) {
33
83
  if (this.killed)
34
84
  return;
35
85
  if (!this.enabled)
36
86
  return;
87
+ if (!this.subs.length)
88
+ return;
37
89
  if (!this.filters.isEmpty && !this.filters.processChain(value).isOK)
38
90
  return;
39
91
  this.process = true;
40
- this.value = value;
41
- for (let i = 0; i < this.subs.length; i++)
42
- this.subs[i].send(value);
92
+ this._value = value;
93
+ const subs = this.subs;
94
+ const len = subs.length;
95
+ for (let i = 0; i < len; i++)
96
+ subs[i].send(value);
43
97
  this.process = false;
44
98
  this.trash.length && this.clearTrash();
45
99
  }
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
+ */
46
107
  stream(values) {
47
108
  if (this.killed)
48
109
  return;
@@ -51,12 +112,24 @@ class Observable {
51
112
  for (let i = 0; i < values.length; i++)
52
113
  this.next(values[i]);
53
114
  }
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
+ */
54
120
  clearTrash() {
55
121
  const length = this.trash.length;
56
122
  for (let i = 0; i < length; i++)
57
123
  this.unSubscribe(this.trash[i]);
58
124
  this.trash.length = 0;
59
125
  }
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
+ */
60
133
  unSubscribe(listener) {
61
134
  if (this.killed)
62
135
  return;
@@ -66,38 +139,76 @@ class Observable {
66
139
  }
67
140
  this.subs && !(0, FunctionLibs_1.quickDeleteFromArray)(this.subs, listener);
68
141
  }
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
+ */
69
150
  destroy() {
70
151
  if (this.killed)
71
152
  return;
72
153
  this.killed = true;
73
154
  if (!this.process) {
74
- this.value = null;
155
+ this._value = null;
75
156
  this.subs.length = 0;
76
157
  return;
77
158
  }
78
- const timer = setInterval(() => {
79
- if (this.process)
80
- return;
81
- clearInterval(timer);
82
- this.value = null;
159
+ Promise.resolve().then(() => {
160
+ this._value = null;
83
161
  this.subs.length = 0;
84
- }, 10);
162
+ });
85
163
  }
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
+ */
86
171
  unsubscribeAll() {
87
172
  if (this.killed)
88
173
  return;
174
+ if (this.process) {
175
+ // Defer removal until next() completes
176
+ const subs = this.subs;
177
+ for (let i = 0; i < subs.length; i++)
178
+ this.trash.push(subs[i]);
179
+ return;
180
+ }
89
181
  this.subs.length = 0;
90
182
  }
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
+ */
91
189
  getValue() {
92
190
  if (this.killed)
93
191
  return undefined;
94
- return this.value;
192
+ return this._value;
95
193
  }
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
+ */
96
199
  size() {
97
200
  if (this.killed)
98
201
  return 0;
99
202
  return this.subs.length;
100
203
  }
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
+ */
101
212
  subscribe(observer, errorHandler) {
102
213
  if (this.killed)
103
214
  return undefined;
@@ -107,15 +218,37 @@ class Observable {
107
218
  this.addObserver(subscribeObject, observer, errorHandler);
108
219
  return subscribeObject;
109
220
  }
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
+ */
110
230
  addObserver(subscribeObject, observer, errorHandler) {
111
231
  subscribeObject.subscribe(observer, errorHandler);
112
232
  this.subs.push(subscribeObject);
113
233
  }
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
+ */
114
240
  isListener(listener) {
115
241
  if (this.killed)
116
242
  return false;
117
243
  return !!listener;
118
244
  }
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
+ */
119
252
  pipe() {
120
253
  if (this.killed)
121
254
  return undefined;
@@ -123,6 +256,11 @@ class Observable {
123
256
  this.subs.push(subscribeObject);
124
257
  return subscribeObject;
125
258
  }
259
+ /**
260
+ * Determines if the object has been destroyed.
261
+ *
262
+ * @return {boolean} True if the object is destroyed, false otherwise.
263
+ */
126
264
  get isDestroyed() {
127
265
  return this.killed;
128
266
  }
@@ -1,11 +1,70 @@
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
+ */
3
15
  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
+ */
4
25
  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
+ */
5
31
  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
+ */
6
37
  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
+ */
7
43
  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
+ */
8
51
  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
+ */
9
59
  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
+ */
10
69
  unSubscribe(listener: ISubscriptionLike): void;
11
70
  }