@akc42/app-utils 5.0.13 → 5.0.14

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.
Files changed (2) hide show
  1. package/api.js +8 -8
  2. package/package.json +1 -1
package/api.js CHANGED
@@ -24,8 +24,11 @@ class ApiError extends Error {
24
24
  this.name = 'API' + code.toString();
25
25
  }
26
26
  }
27
-
28
- const apiEvent = new CustomEvent('api-complete',{bubbles:true, composed: true});
27
+ class ApiEvent extends CustomEvent {
28
+ constructor(message) {
29
+ super ('api-complete', {bubbles: true, composed: true, detail: message});
30
+ }
31
+ }
29
32
  const waitEvent = new CustomEvent('wait-request', {bubbles: true, composed: true, detail: false});
30
33
 
31
34
  async function api(url, params, bl) {
@@ -57,21 +60,18 @@ async function api(url, params, bl) {
57
60
  'chrome=yes,centerscreen,resizable,scrollbars,status,height=800,width=800');
58
61
 
59
62
  document.body.dispatchEvent(waitEvent);
60
- apiEvent.detail = address + ' blob received';
61
- document.body.dispatchEvent(apiEvent)
63
+ document.body.dispatchEvent(new ApiEvent(address + ': blob received'))
62
64
  return {};
63
65
  } else {
64
66
  text = await response.text();
65
67
  if (text.length > 0) {
66
68
  const j = JSON.parse(text);
67
69
  document.body.dispatchEvent(waitEvent);
68
- apiEvent.detail = address + ': ' + JSON.stringify(j)
69
- document.body.dispatchEvent(apiEvent);
70
+ document.body.dispatchEvent(new ApiEvent(address + ': ' + JSON.stringify(j)));
70
71
  return j;
71
72
  }
72
73
  document.body.dispatchEvent(waitEvent);
73
- apiEvent.detail = address + ': {}';
74
- document.body.dispatchEvent(apiEvent);
74
+ document.body.dispatchEvent(new ApiEvent(address + ': {}'));
75
75
  return {};
76
76
  }
77
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akc42/app-utils",
3
- "version": "5.0.13",
3
+ "version": "5.0.14",
4
4
  "description": "General Utilities for SPAs",
5
5
  "main": "app-utils.js",
6
6
  "scripts": {