@arrai-innovations/reactive-helpers 10.1.0 → 10.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -87,7 +87,11 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
87
87
  calculatedObjectsEffectScopes[objectKey].run(() => {
88
88
  for (const addedRuleKey of addedRuleKeys) {
89
89
  calculatedObjectsObject[addedRuleKey] = computed(() =>
90
- state.calculatedObjectsRules?.[addedRuleKey]?.(unref(originalObject), unref(relatedObject))
90
+ state.calculatedObjectsRules?.[addedRuleKey]?.(
91
+ unref(originalObject),
92
+ unref(relatedObject),
93
+ calculatedObjectsObject
94
+ )
91
95
  );
92
96
  }
93
97
  });
package/utils/watches.js CHANGED
@@ -86,7 +86,9 @@ export function doAwaitTimeout(timeout) {
86
86
 
87
87
  export class AwaitNot {
88
88
  constructor({ obj, prop, couldAlreadyBeFalse = false, timeout = 1000 }) {
89
- this.timeout = new AwaitTimeout({ timeout });
89
+ if (timeout > 0) {
90
+ this.timeout = new AwaitTimeout({ timeout });
91
+ }
90
92
  this.promise = new Promise((resolve, reject) => {
91
93
  this.resolve = resolve;
92
94
  this.reject = reject;
@@ -97,22 +99,32 @@ export class AwaitNot {
97
99
  this.trueISW = new ImmediateStopWatch();
98
100
  this.falseISW = new ImmediateStopWatch();
99
101
  // prebuild the exception for a more useful stack.
100
- this.timeoutError = new AwaitNotError("Timeout", "timeout");
102
+ if (this.timeout) {
103
+ this.timeoutError = new AwaitTimeoutError("Timeout", "timeout");
104
+ }
101
105
  }
102
106
 
103
107
  start() {
104
- this.timeout.promise
105
- .then(() => {
106
- this.stop();
107
- this.reject(this.timeoutError);
108
- })
109
- .catch((err) => {
110
- this.stop();
111
- if (!(err instanceof AwaitTimeoutError)) {
112
- this.reject(err);
113
- }
114
- });
115
- this.timeout.start();
108
+ if (this.timeout) {
109
+ this.timeout.promise
110
+ .then(() => {
111
+ if (this.reject) {
112
+ this.reject(this.timeoutError);
113
+ }
114
+ this.stop();
115
+ this.cleanPromise();
116
+ })
117
+ .catch((err) => {
118
+ if (!(err instanceof AwaitTimeoutError)) {
119
+ if (this.reject) {
120
+ this.reject(err);
121
+ }
122
+ this.cleanPromise();
123
+ }
124
+ this.stop();
125
+ });
126
+ this.timeout.start();
127
+ }
116
128
  if (this.obj[this.prop] === false && this.couldAlreadyBeFalse) {
117
129
  this.waitForTrue();
118
130
  } else {
@@ -146,7 +158,10 @@ export class AwaitNot {
146
158
  (newValue) => {
147
159
  if (newValue === false) {
148
160
  this.stop();
149
- this.resolve();
161
+ if (this.resolve) {
162
+ this.resolve();
163
+ }
164
+ this.cleanPromise();
150
165
  }
151
166
  },
152
167
  [this.obj[this.prop]]
@@ -161,10 +176,21 @@ export class AwaitNot {
161
176
  }
162
177
 
163
178
  stop() {
164
- this.timeout.stop();
179
+ if (this.timeout) {
180
+ this.timeout.stop();
181
+ }
165
182
  this.stopTrue();
166
183
  this.stopFalse();
167
184
  }
185
+
186
+ cleanPromise() {
187
+ if (this.resolve) {
188
+ delete this.resolve;
189
+ }
190
+ if (this.reject) {
191
+ delete this.reject;
192
+ }
193
+ }
168
194
  }
169
195
 
170
196
  export function doAwaitNot({ obj, prop, couldAlreadyBeFalse = true, timeout = 1000 }) {