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 | undefined; private nodes = shallowRef(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) => { this.treeWatcher = treeWatcher; return { nodes: shallowReadonly(this.nodes), }; }; } }