diff --git a/ui/element/src/mixins/signal.ts b/ui/element/src/mixins/signal.ts index ea7bc796e..4934bd165 100644 --- a/ui/element/src/mixins/signal.ts +++ b/ui/element/src/mixins/signal.ts @@ -1,22 +1,24 @@ +import {unsubscribe} from '@alwatr/signal/core2.js'; + +import type {ListenerSpec} from '@alwatr/signal/type.js'; import type {Constructor} from '@alwatr/type'; import type {LitElement} from 'lit'; export declare class SignalMixinInterface extends LitElement { - protected _signalListenerList: Array; + protected _signalListenerList: Array; } export function SignalMixin>(superClass: T): Constructor & T { class SignalMixinClass extends superClass { - protected _signalListenerList: Array> = []; + protected _signalListenerList: Array = []; override disconnectedCallback(): void { - super.disconnectedCallback(); - for (const listener of this._signalListenerList) { - if (typeof listener.remove === 'function') { - listener.remove(); - } + unsubscribe(listener); } + this._signalListenerList.length = 0; + this._signalListenerList = []; + super.disconnectedCallback(); } }