- Replace `ref`s with `shallowRef` when deep reactivity is not needed. - Replace `readonly`s with `shallowReadonly` where the goal is to only prevent `.value` mutation. - Remove redundant `ref` in `SizeObserver.vue`. - Remove redundant nested `ref` in `TooltipWrapper.vue`. - Remove redundant `events` export from `UseCollectionState.ts`. - Remove redundant `computed` from `UseCollectionState.ts`. - Remove `timestamp` from `TreeViewFilterEvent` that becomes unnecessary after using `shallowRef`. - Add missing unit tests for `UseTreeViewFilterEvent`. - Add missing stub for `FilterChangeDetails`.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import {
|
|
WatchSource, shallowReadonly, shallowRef, triggerRef,
|
|
} from 'vue';
|
|
import { TreeRoot } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/TreeRoot';
|
|
import { useCurrentTreeNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/UseCurrentTreeNodes';
|
|
import { QueryableNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/Query/QueryableNodes';
|
|
import { QueryableNodesStub } from './QueryableNodesStub';
|
|
|
|
export class UseCurrentTreeNodesStub {
|
|
public treeWatcher: WatchSource<TreeRoot> | undefined;
|
|
|
|
private nodes = shallowRef<QueryableNodes>(new QueryableNodesStub());
|
|
|
|
public withQueryableNodes(nodes: QueryableNodes): this {
|
|
this.nodes.value = nodes;
|
|
return this;
|
|
}
|
|
|
|
public triggerNewNodes(nodes: QueryableNodes) {
|
|
this.nodes.value = nodes;
|
|
triggerRef(this.nodes);
|
|
}
|
|
|
|
public get(): typeof useCurrentTreeNodes {
|
|
return (treeWatcher: WatchSource<TreeRoot>) => {
|
|
this.treeWatcher = treeWatcher;
|
|
return {
|
|
nodes: shallowReadonly(this.nodes),
|
|
};
|
|
};
|
|
}
|
|
}
|