How to check if the tree is ready
Closed this issue · 3 comments
kueronya commented
Hi there, thank you for your great project.
I have an effect like this running
watchEffect(() => {
if (treeItems.value !== null && tree.value !== null) {
if (treeItems.value.length > 0) {
walkTreeData(treeItems, (node: any, index: number) => {
const stat = tree.value!.getStat(node)
});
}
}
});
But on page load it's throwing a StatNotFoundError: Stat not found error.
I guess the tree has not been built fully, because calling walkTreeData() after some timeout works as expected
setTimeout(() => {
walkTreeData(treeItems, (node: any, index: number) => {
const stat = tree.value!.getStat(node)
});
}, 1000);
Is there a safe way to check if the tree is ready to iterate it's data?
phphe commented
no, there isn't
kueronya commented
no, there isn't
Alright, thx for the quick answer.
kueronya commented
Looks like statHandler can be used as a workaround.
Counting the created stats and comparing against the total number of items (flattened children ofc) worked for me.