remove event listeners prevents memory leaks

This commit is contained in:
Maurits Lourens 2021-07-26 23:53:11 +02:00
parent 1497f3f680
commit 7173be59c6
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { onMount } from "svelte" import { onMount, onDestroy } from "svelte"
import { store, currentAsset } from "builderStore" import { store, currentAsset } from "builderStore"
import iframeTemplate from "./iframeTemplate" import iframeTemplate from "./iframeTemplate"
import { Screen } from "builderStore/store/screenTemplates/utils/Screen" import { Screen } from "builderStore/store/screenTemplates/utils/Screen"
@ -120,6 +120,14 @@
}) })
}) })
// remove all iframe event listeners on component destroy
onDestroy(() => {
iframe.contentWindow.removeEventListener("ready")
iframe.contentWindow.removeEventListener("error")
iframe.contentWindow.removeEventListener("bb-event")
iframe.contentWindow.removeEventListener("keydown")
})
const confirmDeleteComponent = (componentId) => { const confirmDeleteComponent = (componentId) => {
idToDelete = componentId idToDelete = componentId
confirmDeleteDialog.show() confirmDeleteDialog.show()