@esportsplus/reactivity 0.0.1 → 0.0.2
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/index.d.ts +2 -18
- package/build/index.js +1 -1
- package/build/obj.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -4
- package/src/obj.ts +2 -2
package/build/index.d.ts
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
private fn?;
|
|
4
|
-
private observers;
|
|
5
|
-
private sources;
|
|
6
|
-
private state;
|
|
7
|
-
private value;
|
|
8
|
-
cleanup: ((old: T) => void)[] | null;
|
|
9
|
-
constructor(_: ((fn: VoidFunction) => T) | T, effect?: boolean);
|
|
10
|
-
get(): T;
|
|
11
|
-
set(value: T): void;
|
|
12
|
-
private mark;
|
|
13
|
-
private removeParentObservers;
|
|
14
|
-
private sync;
|
|
15
|
-
private update;
|
|
16
|
-
}
|
|
17
|
-
declare const effect: <T>(value: () => T) => Reactive<T>;
|
|
18
|
-
declare const reactive: <T>(value: T) => {};
|
|
1
|
+
declare const effect: <T>(value: () => T) => void;
|
|
2
|
+
declare const reactive: <T>(value: T) => T;
|
|
19
3
|
declare const tick: () => void;
|
|
20
4
|
export { effect, reactive, tick };
|
package/build/index.js
CHANGED
package/build/obj.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const factory: (values:
|
|
1
|
+
declare const factory: <T>(values: T) => T;
|
|
2
2
|
export default factory;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -219,15 +219,15 @@ class Reactive<T> {
|
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
const effect = <T>(value: () => T) => {
|
|
222
|
-
|
|
222
|
+
new Reactive(value, true);
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
-
const reactive = <T>(value: T) => {
|
|
225
|
+
const reactive = <T>(value: T): T => {
|
|
226
226
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
227
|
-
return obj(value
|
|
227
|
+
return obj(value);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
return new Reactive(value);
|
|
230
|
+
return new Reactive(value) as T;
|
|
231
231
|
};
|
|
232
232
|
|
|
233
233
|
const tick = () => {
|
package/src/obj.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { reactive } from './index';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const factory = (values:
|
|
4
|
+
const factory = <T>(values: T) => {
|
|
5
5
|
let lazy: Record<string, any> = {},
|
|
6
6
|
properties: PropertyDescriptorMap = {};
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ const factory = (values: Record<string, unknown>) => {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
return Object.defineProperties({}, properties);
|
|
34
|
+
return Object.defineProperties({}, properties) as T;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
|