Skip to content

Commit

Permalink
Fix potential double observer issue with resetObserver (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
fukasawah authored Aug 26, 2024
1 parent fcdd60e commit cd5ae8e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/InfiniteLoading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const params: Params = {
},
};
const resetObserver = () => {
observer?.disconnect();
observer = startObserver(params);
};
const stateHandler: StateHandler = {
loading() {
state.value = "loading";
Expand All @@ -58,13 +63,12 @@ const stateHandler: StateHandler = {
};
watch(identifier, () => {
observer?.disconnect();
observer = startObserver(params);
resetObserver();
});
onMounted(async () => {
params.parentEl = await getParentEl(target!);
observer = startObserver(params);
resetObserver();
});
onUnmounted(() => {
Expand Down

0 comments on commit cd5ae8e

Please sign in to comment.