Skip to content

Commit

Permalink
Merge pull request #148 from TaTo30/fix/issue130
Browse files Browse the repository at this point in the history
Destroy the worker when the component has been unmounted
  • Loading branch information
TaTo30 authored Sep 8, 2024
2 parents 2b2c3f9 + 37acf9b commit 900c710
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 900c710

Please sign in to comment.