@esportsplus/reactivity 0.2.5 → 0.2.6
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/build/reactive/array.js +12 -4
- package/package.json +1 -1
- package/src/reactive/array.ts +15 -4
package/build/reactive/array.js
CHANGED
|
@@ -6,7 +6,10 @@ class ReactiveArray extends Array {
|
|
|
6
6
|
proxy;
|
|
7
7
|
signal;
|
|
8
8
|
constructor(data, proxy, options = {}) {
|
|
9
|
-
super(
|
|
9
|
+
super();
|
|
10
|
+
for (let i = 0, n = data.length; i < n; i++) {
|
|
11
|
+
super.push(data[i]);
|
|
12
|
+
}
|
|
10
13
|
this.options = options;
|
|
11
14
|
this.proxy = proxy;
|
|
12
15
|
this.signal = signal(false);
|
|
@@ -158,11 +161,16 @@ export default (input, options = {}) => {
|
|
|
158
161
|
set(_, key, value) {
|
|
159
162
|
if (isNumber(key)) {
|
|
160
163
|
let host = a[key];
|
|
161
|
-
if (
|
|
164
|
+
if (host === undefined) {
|
|
165
|
+
a[key] = factory([value], options)[0];
|
|
166
|
+
}
|
|
167
|
+
else if (isInstanceOf(host, Reactive)) {
|
|
162
168
|
host.set(value);
|
|
163
|
-
return true;
|
|
164
169
|
}
|
|
165
|
-
|
|
170
|
+
else {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
166
174
|
}
|
|
167
175
|
return a[key] = value;
|
|
168
176
|
}
|
package/package.json
CHANGED
package/src/reactive/array.ts
CHANGED
|
@@ -46,7 +46,13 @@ class ReactiveArray<T> extends Array<Item<T>> {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
constructor(data: Item<T>[], proxy: API<T>, options: Options = {}) {
|
|
49
|
-
super(
|
|
49
|
+
super();
|
|
50
|
+
|
|
51
|
+
// Only method I could use to prevent TS and runtime JS errors
|
|
52
|
+
for (let i = 0, n = data.length; i < n; i++) {
|
|
53
|
+
super.push(data[i]);
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
this.options = options;
|
|
51
57
|
this.proxy = proxy;
|
|
52
58
|
this.signal = signal(false);
|
|
@@ -283,12 +289,17 @@ export default <T>(input: T[], options: Options = {}) => {
|
|
|
283
289
|
if (isNumber(key)) {
|
|
284
290
|
let host = a[key];
|
|
285
291
|
|
|
286
|
-
if (
|
|
292
|
+
if (host === undefined) {
|
|
293
|
+
a[key] = factory([value] as T[], options)[0];
|
|
294
|
+
}
|
|
295
|
+
else if (isInstanceOf(host, Reactive)) {
|
|
287
296
|
host.set(value);
|
|
288
|
-
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return false;
|
|
289
300
|
}
|
|
290
301
|
|
|
291
|
-
return
|
|
302
|
+
return true;
|
|
292
303
|
}
|
|
293
304
|
|
|
294
305
|
return a[key] = value;
|