From 3f9b99d65db2d6d8b57dbb242f2c56c70f3a932b Mon Sep 17 00:00:00 2001 From: Ian Silva Date: Thu, 7 Mar 2024 11:20:56 -0300 Subject: [PATCH] fix: unsubscribe from subjects when destroying room --- src/common/utils/use-store.ts | 2 +- src/components/base/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/utils/use-store.ts b/src/common/utils/use-store.ts index 45cc381b..40d78ed6 100644 --- a/src/common/utils/use-store.ts +++ b/src/common/utils/use-store.ts @@ -1,6 +1,6 @@ import { PublicSubject } from '../../services/stores/common/types'; import { useGlobalStore } from '../../services/stores/global'; -import { Store, StoreType, StoresTypes } from '../types/stores.types'; +import { Store, StoreType } from '../types/stores.types'; const stores = { [StoreType.GLOBAL]: useGlobalStore, diff --git a/src/components/base/index.ts b/src/components/base/index.ts index 30a17bdb..cc38a38b 100644 --- a/src/components/base/index.ts +++ b/src/components/base/index.ts @@ -79,6 +79,7 @@ export abstract class BaseComponent extends Observable { this.logger.log('detached'); this.publish(ComponentLifeCycleEvent.UNMOUNT); this.destroy(); + this.unsubscribeFrom.forEach((unsubscribe) => unsubscribe(this)); Object.values(this.observers).forEach((observer) => { observer.reset();