@azure-net/kit 0.9.3 → 0.9.4

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.
@@ -4,6 +4,7 @@ export interface AsyncSignalOptions<TData> {
4
4
  immediate?: boolean;
5
5
  watch?: (() => unknown)[];
6
6
  initialData?: TData | null;
7
+ key?: string;
7
8
  }
8
9
  export interface AsyncSignalSvelte<TData, TError = Error> {
9
10
  data: TData | null;
@@ -15,4 +16,8 @@ export interface AsyncSignalSvelte<TData, TError = Error> {
15
16
  reset: () => void;
16
17
  abort: () => void;
17
18
  }
19
+ export declare const createSignalManager: () => {
20
+ refreshAll: () => Promise<void>;
21
+ refreshByKey: (key: string) => Promise<void>;
22
+ };
18
23
  export declare const createAsyncSignal: <TData, TError = Error>(handler: (signal?: AbortSignal) => Promise<TData>, options?: AsyncSignalOptions<TData>) => AsyncSignalSvelte<TData, TError>;
@@ -1,5 +1,16 @@
1
1
  import { untrack } from 'svelte';
2
2
  import { EnvironmentUtil } from 'azure-net-tools';
3
+ export const createSignalManager = () => {
4
+ const instances = new Map;
5
+ const refreshByKey = async (key) => {
6
+ const instance = instances.get(key);
7
+ await instance?.();
8
+ };
9
+ const refreshAll = async () => {
10
+ await Promise.all(instances.values().map(val => val()));
11
+ };
12
+ return { refreshAll, refreshByKey };
13
+ };
3
14
  export const createAsyncSignal = (handler, options = {}) => {
4
15
  const { server = false, immediate = true, watch = [], initialData = null } = options;
5
16
  let data = $state(initialData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -96,7 +96,7 @@
96
96
  "svelte"
97
97
  ],
98
98
  "dependencies": {
99
- "azure-net-tools": "^1.1.0",
99
+ "azure-net-tools": "^1.1.1",
100
100
  "edges-svelte": "^1.1.0",
101
101
  "edges-svelte-translations": "^0.2.0",
102
102
  "ky": "^1.8.1",