Skip to content

Commit

Permalink
Destroy the worker when the component has been unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
TaTo30 committed Sep 8, 2024
1 parent 2b2c3f9 commit 37acf9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vue-pdf/src/components/VuePDF.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- eslint-disable no-case-declarations -->
<script setup lang="ts">
import * as PDFJS from 'pdfjs-dist'
import { computed, onMounted, ref, toRaw, watch } from 'vue'
import { computed, onMounted, onUnmounted, ref, toRaw, watch } from 'vue'

import 'pdfjs-dist/web/pdf_viewer.css'

Expand Down Expand Up @@ -279,6 +279,11 @@ onMounted(() => {
initDoc(props.pdf)
})

onUnmounted(() => {
// Abort all network process and terminates the worker
props.pdf?.destroy()
})

// Exposed methods
function reload() {
renderPage(props.page)
Expand Down

0 comments on commit 37acf9b

Please sign in to comment.