@asaidimu/utils-workspace 6.5.0 → 6.5.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.
- package/index.d.mts +12 -2
- package/index.d.ts +12 -2
- package/package.json +3 -3
package/index.d.mts
CHANGED
|
@@ -430,16 +430,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
|
|
|
430
430
|
* Subscribes to a specific event by name.
|
|
431
431
|
* @param eventName - The name of the event to subscribe to.
|
|
432
432
|
* @param callback - The function to call when the event is emitted.
|
|
433
|
+
* @param options - Extra options to determine the behaviour of the
|
|
434
|
+
* subscription
|
|
433
435
|
* @returns A function to unsubscribe from the event.
|
|
434
436
|
*/
|
|
435
|
-
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
437
|
+
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
436
438
|
/**
|
|
437
439
|
* Subscribes to an event and automatically unsubscribes after it fires once.
|
|
438
440
|
* @param eventName - The name of the event to subscribe to.
|
|
439
441
|
* @param callback - The function to call when the event is emitted.
|
|
440
442
|
* @returns A function to cancel the one-shot subscription before it fires.
|
|
441
443
|
*/
|
|
442
|
-
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
444
|
+
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
443
445
|
/**
|
|
444
446
|
* Emits an event with a payload to all subscribed listeners.
|
|
445
447
|
* @param event - An object containing the event name and payload.
|
|
@@ -473,6 +475,14 @@ interface EventMetrics {
|
|
|
473
475
|
/** Average duration of event dispatch in milliseconds. */
|
|
474
476
|
averageEmitDuration: number;
|
|
475
477
|
}
|
|
478
|
+
interface SubscribeOptions {
|
|
479
|
+
/**
|
|
480
|
+
* Debounce delay in milliseconds. When multiple events arrive in quick
|
|
481
|
+
* succession, the callback runs only after the quiet period ends, using the
|
|
482
|
+
* latest payload. Default = no debouncing.
|
|
483
|
+
*/
|
|
484
|
+
debounce?: number;
|
|
485
|
+
}
|
|
476
486
|
|
|
477
487
|
/**
|
|
478
488
|
* Utility type for representing partial updates to the state, allowing deep nesting.
|
package/index.d.ts
CHANGED
|
@@ -430,16 +430,18 @@ interface EventBus<TEventMap extends Record<string, any>> {
|
|
|
430
430
|
* Subscribes to a specific event by name.
|
|
431
431
|
* @param eventName - The name of the event to subscribe to.
|
|
432
432
|
* @param callback - The function to call when the event is emitted.
|
|
433
|
+
* @param options - Extra options to determine the behaviour of the
|
|
434
|
+
* subscription
|
|
433
435
|
* @returns A function to unsubscribe from the event.
|
|
434
436
|
*/
|
|
435
|
-
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
437
|
+
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
436
438
|
/**
|
|
437
439
|
* Subscribes to an event and automatically unsubscribes after it fires once.
|
|
438
440
|
* @param eventName - The name of the event to subscribe to.
|
|
439
441
|
* @param callback - The function to call when the event is emitted.
|
|
440
442
|
* @returns A function to cancel the one-shot subscription before it fires.
|
|
441
443
|
*/
|
|
442
|
-
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
444
|
+
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void, options?: SubscribeOptions) => () => void;
|
|
443
445
|
/**
|
|
444
446
|
* Emits an event with a payload to all subscribed listeners.
|
|
445
447
|
* @param event - An object containing the event name and payload.
|
|
@@ -473,6 +475,14 @@ interface EventMetrics {
|
|
|
473
475
|
/** Average duration of event dispatch in milliseconds. */
|
|
474
476
|
averageEmitDuration: number;
|
|
475
477
|
}
|
|
478
|
+
interface SubscribeOptions {
|
|
479
|
+
/**
|
|
480
|
+
* Debounce delay in milliseconds. When multiple events arrive in quick
|
|
481
|
+
* succession, the callback runs only after the quiet period ends, using the
|
|
482
|
+
* latest payload. Default = no debouncing.
|
|
483
|
+
*/
|
|
484
|
+
debounce?: number;
|
|
485
|
+
}
|
|
476
486
|
|
|
477
487
|
/**
|
|
478
488
|
* Utility type for representing partial updates to the state, allowing deep nesting.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asaidimu/utils-workspace",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.1",
|
|
4
4
|
"description": "Content-addressed workspace and conversation management for AI applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@google/genai": "^1.50.1"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@asaidimu/utils-database": "3.1.
|
|
67
|
-
"@asaidimu/utils-events": "1.
|
|
66
|
+
"@asaidimu/utils-database": "^3.1.2",
|
|
67
|
+
"@asaidimu/utils-events": "^1.0.0",
|
|
68
68
|
"@asaidimu/anansi": "^4.0.2",
|
|
69
69
|
"uuid": "^13.0.0"
|
|
70
70
|
}
|