@azure-net/kit 1.2.0 → 1.2.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,4 +1,5 @@
1
1
  import { createErrorParser } from './ErrorHandler.js';
2
+ import { AppEventBus } from '../../index.js';
2
3
  export const createAsyncHelpers = (opts) => {
3
4
  const errorParser = opts?.parseError ?? createErrorParser();
4
5
  const createAsyncAction = async (action, args) => {
@@ -25,10 +26,11 @@ export const createAsyncHelpers = (opts) => {
25
26
  }
26
27
  catch (err) {
27
28
  const error = errorParser(err);
28
- if (args?.reject)
29
- throw error;
29
+ AppEventBus.publish('OnAsyncHelperError', error);
30
30
  const result = { error, response: args?.fallbackResponse, success: false };
31
31
  await args?.onError?.(result);
32
+ if (args?.reject)
33
+ throw error;
32
34
  return result;
33
35
  }
34
36
  };
@@ -44,6 +46,7 @@ export const createAsyncHelpers = (opts) => {
44
46
  }
45
47
  catch (err) {
46
48
  const error = errorParser(err);
49
+ AppEventBus.publish('OnAsyncHelperError', error);
47
50
  await args?.onError?.(error);
48
51
  if (args?.reject)
49
52
  throw error;
@@ -3,5 +3,6 @@ export * from './shared/middleware/index.js';
3
3
  export * from './shared/classMirror/index.js';
4
4
  export * from './shared/cookie/index.js';
5
5
  export * from './shared/boundaryProvider/index.js';
6
+ export * from './shared/appEventBus/index.js';
6
7
  export * from './ui/index.js';
7
8
  export * from './svelte/index.js';
@@ -3,5 +3,6 @@ export * from './shared/middleware/index.js';
3
3
  export * from './shared/classMirror/index.js';
4
4
  export * from './shared/cookie/index.js';
5
5
  export * from './shared/boundaryProvider/index.js';
6
+ export * from './shared/appEventBus/index.js';
6
7
  export * from './ui/index.js';
7
8
  export * from './svelte/index.js';
@@ -0,0 +1,2 @@
1
+ import { EventBus } from 'azure-net-tools';
2
+ export declare const AppEventBus: EventBus<"OnHttpError" | "OnAsyncHelperError">;
@@ -0,0 +1,2 @@
1
+ import { EventBus } from 'azure-net-tools';
2
+ export const AppEventBus = new EventBus();
@@ -0,0 +1 @@
1
+ export * from './EventBus.js';
@@ -0,0 +1 @@
1
+ export * from './EventBus.js';
@@ -8,7 +8,7 @@ export const createActiveForm = (onSubmit, config) => {
8
8
  const submit = async () => {
9
9
  pending = true;
10
10
  try {
11
- const result = await onSubmit(formData);
11
+ const result = await onSubmit(ObjectUtil.deepClone(formData));
12
12
  if (result.error?.fields) {
13
13
  formErrors = result.error.fields;
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",