refactor: misc

This commit is contained in:
2026-04-04 16:34:17 +08:00
parent 72e159e52b
commit 76687de672
3 changed files with 13 additions and 24 deletions
-16
View File
@@ -1,8 +1,3 @@
import { h, Fragment } from 'preact';
import { effect } from '@preact/signals-core';
type DisposeFn = () => void;
export interface GameUIOptions {
container: HTMLElement;
root: any;
@@ -11,7 +6,6 @@ export interface GameUIOptions {
export class GameUI {
private container: HTMLElement;
private root: any;
private effects: DisposeFn[] = [];
constructor(options: GameUIOptions) {
this.container = options.container;
@@ -24,19 +18,9 @@ export class GameUI {
});
}
watch(fn: () => void): DisposeFn {
const e = effect(fn);
this.effects.push(e);
return e;
}
unmount(): void {
import('preact').then(({ render }) => {
render(null, this.container);
});
for (const e of this.effects) {
e();
}
this.effects = [];
}
}