Skip to content

Commit

Permalink
[#734][3.0] 데이터가 많을 경우 부하 발생 처리에 대한 피드백 반영
Browse files Browse the repository at this point in the history
###########
- 노드가 많아지면 발생할 수 있는 부하에 대한 피드백 반영, 쓰로틀링 방법을 도입하여 수정
  • Loading branch information
BoKyeongShin committed Feb 4, 2021
1 parent e973e2c commit c06eef3
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/components/tree/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</template>

<script>
import { ref, reactive, watch, onMounted } from 'vue';
import { ref, reactive, watch, onMounted, onBeforeUnmount } from 'vue';
import TreeNode from './TreeNode';
export default {
Expand Down Expand Up @@ -260,15 +260,21 @@ export default {
});
let timer;
watch(() => props.searchWord, (newSearchWord) => {
if (newSearchWord) {
filterNode(newSearchWord);
} else {
allNodeInfo.forEach((nodeObj) => {
const node = nodeObj.node;
node.visible = true;
});
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
if (newSearchWord) {
filterNode(newSearchWord);
} else {
allNodeInfo.forEach((nodeObj) => {
const node = nodeObj.node;
node.visible = true;
});
}
}, 200);
});
onMounted(() => {
Expand All @@ -281,6 +287,11 @@ export default {
})));
}
});
onBeforeUnmount(() => {
if (timer) {
clearTimeout(timer);
}
});
return {
treeNodeData,
Expand Down

0 comments on commit c06eef3

Please sign in to comment.