Skip to content

Commit

Permalink
fix(mixins): export as type
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Apr 19, 2024
1 parent a5806c3 commit e92241c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/mixins/src/lib/schedule-update-to-frame.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {cancelNextAnimationFrame, nextAnimationFrame} from '@gecut/utilities/wait/polyfill.js';

import {SignalMixinInterface} from './signal.js';

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type {SignalMixinInterface} from './signal.js';
import type {Constructor} from '@gecut/types';

export declare class ScheduleUpdateToFrameMixinInterface extends SignalMixinInterface {}
Expand Down
10 changes: 5 additions & 5 deletions packages/mixins/src/lib/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ export type MixinReturn<T> = Constructor<SignalMixinInterface> & T;
export function SignalMixin<T extends Constructor<LitElement>>(superClass: T): MixinReturn<T> {
class SignalMixinClass extends superClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private signalSubscribers: [Signal<any>, Subscriber<any>][] = [];
private signalSubscribers: ReturnType<Signal<any>['subscribe']>[] = [];

override disconnectedCallback(): void {
super.disconnectedCallback();

for (const [signal, subscriber] of this.signalSubscribers) {
signal.unsubscribe(subscriber);
for (const signalReturn of this.signalSubscribers) {
signalReturn.unsubscribe();
}
}

protected addSignalSubscriber<T, S extends Signal<T>>(signal: S, subscriber: Subscriber<T>): void {
this.signalSubscribers.push([signal, subscriber]);
protected addSignalSubscriber<T, S extends Signal<T>>(signalReturn: ReturnType<S['subscribe']>): void {
this.signalSubscribers.push(signalReturn);
}
}

Expand Down

0 comments on commit e92241c

Please sign in to comment.