From f492b502198189adb36867e256f3f4a274e9d027 Mon Sep 17 00:00:00 2001
From: Eugen Neuber <eugen.neuber@tugraz.at>
Date: Wed, 3 Feb 2021 09:38:19 +0100
Subject: [PATCH] Add unsubscribing attributes on disconnectedCallback()

Uses subscribe attribute
---
 packages/provider/src/adapter-lit-element.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/packages/provider/src/adapter-lit-element.js b/packages/provider/src/adapter-lit-element.js
index 9c832aa0..3635d6e5 100644
--- a/packages/provider/src/adapter-lit-element.js
+++ b/packages/provider/src/adapter-lit-element.js
@@ -172,6 +172,13 @@ export class AdapterLitElement extends LitElement {
         }
     }
 
+    disconnectedCallback() {
+        const attrs = this.subscribe.split(',');
+        attrs.forEach(element => this.unSubscribeProviderFor(element));
+
+        super.disconnectedCallback();
+    }
+
     subscribeProviderFor(element) {
         console.log('AdapterLitElement(' + this.tagName + ') subscribeProviderFor( ' + element + ' )');
         const pair = element.trim().split(':');
-- 
GitLab