@angular-wave/angular.ts 0.14.0 → 0.14.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.
@@ -165,14 +165,14 @@ export class NgModule {
165
165
  ): NgModule;
166
166
  /**
167
167
  * @param {string} name
168
- * @param {Function} ctor
168
+ * @param {Function|Object} ctor - A regular function, an arrow function or an object
169
169
  * @param {ng.StorageType} type
170
170
  * @param {ng.StorageBackend} [backendOrConfig]
171
171
  * @returns {NgModule}
172
172
  */
173
173
  store(
174
174
  name: string,
175
- ctor: Function,
175
+ ctor: Function | any,
176
176
  type: ng.StorageType,
177
177
  backendOrConfig?: ng.StorageBackend,
178
178
  ): NgModule;
@@ -9,174 +9,69 @@ export class PubSubProvider {
9
9
  * @type {PubSub}
10
10
  */
11
11
  eventBus: PubSub;
12
- /**
13
- * @returns {PubSub}
14
- */
15
- $get: () => PubSub;
12
+ $get: any[];
13
+ $exceptionHandler: import("../exception/interface.ts").ExceptionHandler;
16
14
  }
17
15
  export class PubSub {
18
- static $nonscope: any;
19
- /**
20
- * Runs a function asynchronously.
21
- *
22
- * @private
23
- * @param {Function} fn Function to run.
24
- * @param {Object} context Context in which to run the function.
25
- * @param {Array} args Arguments to pass to the function.
26
- */
27
- private static runAsync_;
28
- /**
29
- * Topic-based publish/subscribe channel. Maintains a map of topics to
30
- * subscriptions. When a message is published to a topic, all functions
31
- * subscribed to that topic are invoked in the order they were added.
32
- * Uncaught errors abort publishing.
33
- *
34
- * Topics may be identified by any nonempty string, <strong>except</strong>
35
- * strings corresponding to native Object properties, e.g. "constructor",
36
- * "toString", "hasOwnProperty", etc.
37
- *
38
- * @param {boolean=} async Enable asynchronous behavior. Recommended for
39
- * new code. See notes on the publish() method.
40
- */
41
- constructor(async?: boolean | undefined);
42
- disposed: boolean;
43
- /**
44
- * The next available subscription key. Internally, this is an index into the
45
- * sparse array of subscriptions.
46
- *
47
- * @private {number}
48
- */
49
- private key;
50
- /**
51
- * Array of subscription keys pending removal once publishing is done.
52
- *
53
- * @private {!Array<number>}
54
- * @const
55
- */
56
- private pendingKeys;
16
+ /** @private {Object<string, Array<{fn: Function, context: any}>>} */
17
+ private _topics;
18
+ /** @private */
19
+ private _disposed;
20
+ /** @type {ng.ExceptionHandlerService} */
21
+ $exceptionHandler: ng.ExceptionHandlerService;
57
22
  /**
58
- * Lock to prevent the removal of subscriptions during publishing. Incremented
59
- * at the beginning of {@link #publish}, and decremented at the end.
60
- *
61
- * @private {number}
23
+ * Set instance to initial state
62
24
  */
63
- private publishDepth;
25
+ reset(): void;
64
26
  /**
65
- * Sparse array of subscriptions. Each subscription is represented by a tuple
66
- * comprising a topic identifier, a function, and an optional context object.
67
- * Each tuple occupies three consecutive positions in the array, with the
68
- * topic identifier at index n, the function at index (n + 1), the context
69
- * object at index (n + 2), the next topic at index (n + 3), etc. (This
70
- * representation minimizes the number of object allocations and has been
71
- * shown to be faster than an array of objects with three key-value pairs or
72
- * three parallel arrays, especially on IE.) Once a subscription is removed
73
- * via {@link unsubscribe} or {@link unsubscribeByKey}, the three
74
- * corresponding array elements are deleted, and never reused. This means the
75
- * total number of subscriptions during the lifetime of the pubsub channel is
76
- * limited by the maximum length of a JavaScript array to (2^32 - 1) / 3 =
77
- * 1,431,655,765 subscriptions, which should suffice for most applications.
78
- *
79
- * @private {!Array<?>}
80
- * @const
27
+ * Checks if instance has been disposed.
28
+ * @returns {boolean} True if disposed.
81
29
  */
82
- private subscriptions;
83
- /**
84
- * Map of topics to arrays of subscription keys.
85
- *
86
- * @private {!Object<!Array<number>>}
87
- */
88
- private topics;
89
- /**
90
- * @private @const {boolean}
91
- */
92
- private async_;
93
- /**
94
- * Subscribes a function to a topic. The function is invoked as a method on
95
- * the given `opt_context` object, or in the global scope if no context
96
- * is specified. Subscribing the same function to the same topic multiple
97
- * times will result in multiple function invocations while publishing.
98
- * Returns a subscription key that can be used to unsubscribe the function from
99
- * the topic via {@link unsubscribeByKey}.
100
- *
101
- * @param {string} topic Topic to subscribe to.
102
- * @param {Function} fn Function to be invoked when a message is published to
103
- * the given topic.
104
- * @param {Object=} opt_context Object in whose context the function is to be
105
- * called (the global scope if none).
106
- * @return {number} Subscription key.
107
- */
108
- subscribe(topic: string, fn: Function, opt_context?: any | undefined): number;
30
+ isDisposed(): boolean;
109
31
  /**
110
- * Subscribes a single-use function to a topic. The function is invoked as a
111
- * method on the given `opt_context` object, or in the global scope if
112
- * no context is specified, and is then unsubscribed. Returns a subscription
113
- * key that can be used to unsubscribe the function from the topic via
114
- * {@link unsubscribeByKey}.
115
- *
116
- * @param {string} topic Topic to subscribe to.
117
- * @param {Function} fn Function to be invoked once and then unsubscribed when
118
- * a message is published to the given topic.
119
- * @param {Object=} opt_context Object in whose context the function is to be
120
- * called (the global scope if none).
121
- * @return {number} Subscription key.
32
+ * Dispose the instance, removing all topics and listeners.
122
33
  */
123
- subscribeOnce(
124
- topic: string,
125
- fn: Function,
126
- opt_context?: any | undefined,
127
- ): number;
34
+ dispose(): void;
128
35
  /**
129
- * Unsubscribes a function from a topic. Only deletes the first match found.
130
- * Returns a Boolean indicating whether a subscription was removed.
131
- *
132
- * @param {string} topic Topic to unsubscribe from.
133
- * @param {Function} fn Function to unsubscribe.
134
- * @param {Object=} opt_context Object in whose context the function was to be
135
- * called (the global scope if none).
136
- * @return {boolean} Whether a matching subscription was removed.
36
+ * Subscribe a function to a topic.
37
+ * @param {string} topic - The topic to subscribe to.
38
+ * @param {Function} fn - The callback function to invoke when published.
39
+ * @param {*} [context] - Optional `this` context for the callback.
40
+ * @returns {() => boolean} A function that unsubscribes this listener.
137
41
  */
138
- unsubscribe(
139
- topic: string,
140
- fn: Function,
141
- opt_context?: any | undefined,
142
- ): boolean;
42
+ subscribe(topic: string, fn: Function, context?: any): () => boolean;
143
43
  /**
144
- * Removes a subscription based on the key returned by {@link subscribe}.
145
- * No-op if no matching subscription is found. Returns a Boolean indicating
146
- * whether a subscription was removed.
147
- *
148
- * @param {number} key Subscription key.
149
- * @return {boolean} Whether a matching subscription was removed.
44
+ * Subscribe a function to a topic only once.
45
+ * Listener is removed before the first invocation.
46
+ * @param {string} topic - The topic to subscribe to.
47
+ * @param {Function} fn - The callback function.
48
+ * @param {*} [context] - Optional `this` context for the callback.
49
+ * @returns {() => boolean} A function that unsubscribes this listener.
150
50
  */
151
- unsubscribeByKey(key: number): boolean;
51
+ subscribeOnce(topic: string, fn: Function, context?: any): () => boolean;
152
52
  /**
153
- * Publishes a message to a topic. Calls functions subscribed to the topic in
154
- * the order in which they were added, passing all arguments along.
155
- *
156
- * If this object was created with async=true, subscribed functions are called
157
- * via `queueMicrotask`. Otherwise, the functions are called directly, and if
158
- * any of them throw an uncaught error, publishing is aborted.
159
- *
160
- * @param {string} topic Topic to publish to.
161
- * @param {...*} var_args Arguments that are applied to each subscription
162
- * function.
163
- * @return {boolean} Whether any subscriptions were called.
53
+ * Unsubscribe a specific function from a topic.
54
+ * Matches by function reference and optional context.
55
+ * @param {string} topic - The topic to unsubscribe from.
56
+ * @param {Function} fn - The listener function.
57
+ * @param {*} [context] - Optional `this` context.
58
+ * @returns {boolean} True if the listener was found and removed.
164
59
  */
165
- publish(topic: string, ...var_args: any[]): boolean;
60
+ unsubscribe(topic: string, fn: Function, context?: any): boolean;
166
61
  /**
167
- * Clears the subscription list for a topic, or all topics if unspecified.
168
- * @param {string=} opt_topic Topic to clear (all topics if unspecified).
62
+ * Get the number of subscribers for a topic.
63
+ * @param {string} topic
64
+ * @returns {number}
169
65
  */
170
- clear(opt_topic?: string | undefined): void;
66
+ getCount(topic: string): number;
171
67
  /**
172
- * Returns the number of subscriptions to the given topic (or all topics if
173
- * unspecified). This number will not change while publishing any messages.
174
- * @param {string=} opt_topic The topic (all topics if unspecified).
175
- * @return {number} Number of subscriptions to the topic.
68
+ * Publish a value to a topic asynchronously.
69
+ * All listeners are invoked in the order they were added.
70
+ * @param {string} topic - The topic to publish.
71
+ * @param {...*} args - Arguments to pass to listeners.
72
+ * @returns {boolean} True if any listeners exist for this topic.
176
73
  */
177
- getCount(opt_topic?: string | undefined): number;
178
- isDisposed(): boolean;
179
- dispose(): void;
74
+ publish(topic: string, ...args: any[]): boolean;
180
75
  }
181
76
  export const EventBus: PubSub;
182
77
  /**
@@ -93,10 +93,7 @@ export function notNullOrUndefined(obj: any): boolean;
93
93
  */
94
94
  export function isNumber(value: any): boolean;
95
95
  /**
96
- * @module angular
97
- * @function isDate
98
96
  *
99
- * @description
100
97
  * Determines if a value is a date.
101
98
  *
102
99
  * @param {*} value Reference to check.
@@ -437,6 +434,7 @@ export function assert(argument: boolean, errorMsg?: string): void;
437
434
  /**
438
435
  * Validate a value using a predicate function.
439
436
  * Throws if the predicate returns false.
437
+ * IMPORTANT: use this function only for developper errors and not for user/data errors
440
438
  *
441
439
  * @param {ng.Validator} fn - Predicate validator function.
442
440
  * @param {*} arg - The value to validate.
@@ -459,6 +457,13 @@ export function validateRequired(arg: any, name: string): any;
459
457
  * @throws {TypeError} If the value does not satisfy the validator.
460
458
  */
461
459
  export function validateArray(arg: any, name: string): any;
460
+ /**
461
+ * @param {*} arg - The value to validate.
462
+ * @param {string} name - Parameter name (included in error message).
463
+ * @returns {*} The validated value.
464
+ * @throws {TypeError} If the value does not satisfy the validator.
465
+ */
466
+ export function validateIsString(arg: any, name: string): any;
462
467
  /**
463
468
  * Throw error if the argument is falsy.
464
469
  */
@@ -626,6 +631,11 @@ export function instantiateWasm(
626
631
  exports: WebAssembly.Exports;
627
632
  module: WebAssembly.Module;
628
633
  }>;
634
+ /**
635
+ * @param {*} fn
636
+ * @returns {boolean}
637
+ */
638
+ export function isArrowFunction(fn: any): boolean;
629
639
  export const isProxySymbol: unique symbol;
630
640
  export const BADARG: "badarg";
631
641
  export const BADARGKEY: "badarg: key";