chore: Format files
This commit is contained in:
parent
4de52d8b6e
commit
04b12cc423
|
@ -23,17 +23,17 @@ export type Reactive<T = any> = RNode<T> | Atom<T>;
|
||||||
|
|
||||||
export function createReactive<T extends any>(raw?: T): ReactiveProxy<T> {
|
export function createReactive<T extends any>(raw?: T): ReactiveProxy<T> {
|
||||||
if (isPrimitive(raw) || raw === null || raw === undefined) {
|
if (isPrimitive(raw) || raw === null || raw === undefined) {
|
||||||
return new RNode(raw, {isSignal: true});
|
return new RNode(raw, { isSignal: true });
|
||||||
} else {
|
} else {
|
||||||
const node = new RProxyNode(null, {
|
const node = new RProxyNode(null, {
|
||||||
root: {$: raw},
|
root: { $: raw },
|
||||||
});
|
});
|
||||||
return node.proxy as ReactiveProxy<T>;
|
return node.proxy as ReactiveProxy<T>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createComputed<T>(fn: T) {
|
export function createComputed<T>(fn: T) {
|
||||||
const rNode = new RProxyNode(fn, {isComputed: true});
|
const rNode = new RProxyNode(fn, { isComputed: true });
|
||||||
return rNode.proxy;
|
return rNode.proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,18 +61,21 @@ export function getOrCreateChildRNode(node: RProxyNode<any>, key: string | symbo
|
||||||
// root: node.root,
|
// root: node.root,
|
||||||
// });
|
// });
|
||||||
|
|
||||||
child = new RProxyNode(() => {
|
child = new RProxyNode(
|
||||||
|
() => {
|
||||||
const rootRNode = getRootRNode(node);
|
const rootRNode = getRootRNode(node);
|
||||||
// 依赖根
|
// 依赖根
|
||||||
rootRNode.get();
|
rootRNode.get();
|
||||||
|
|
||||||
return getRNodeVal(node)[key];
|
return getRNodeVal(node)[key];
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
isComputed: true,
|
isComputed: true,
|
||||||
parent: node,
|
parent: node,
|
||||||
key: key,
|
key: key,
|
||||||
root: node.root,
|
root: node.root,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
child.track();
|
child.track();
|
||||||
|
|
Loading…
Reference in New Issue