adds onDestroy handler for auto refresh Data Prov

This commit is contained in:
mikesealey 2025-05-15 16:02:25 +01:00
parent 3e615249d7
commit fd07fd34b9
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { getContext } from "svelte" import { getContext, onDestroy } from "svelte"
import { Pagination, ProgressCircle } from "@budibase/bbui" import { Pagination, ProgressCircle } from "@budibase/bbui"
import { fetchData, QueryUtils } from "@budibase/frontend-core" import { fetchData, QueryUtils } from "@budibase/frontend-core"
import type { import type {
@ -175,6 +175,10 @@
interval = setInterval(fetch.refresh, Math.max(10000, autoRefresh * 1000)) interval = setInterval(fetch.refresh, Math.max(10000, autoRefresh * 1000))
} }
} }
onDestroy(() => {
clearInterval(interval) // Clears auto-refresh when navigating away
})
</script> </script>
<div use:styleable={$component.styles} class="container"> <div use:styleable={$component.styles} class="container">