WindowFormElement

This commit is contained in:
2025-09-16 14:32:57 +08:00
parent 08e08043d7
commit 122fba228a
8 changed files with 737 additions and 386 deletions

View File

@@ -180,7 +180,7 @@ export class ObservableImpl<T extends TNonFunctionProperties<T>> implements IObs
}
/** 订阅整个状态变化 */
subscribe(fn: TObservableListener<T>, options: { immediate?: boolean } = {}): () => void {
public subscribe(fn: TObservableListener<T>, options: { immediate?: boolean } = {}): () => void {
this.listeners.add(fn)
if (options.immediate) fn(this.state)
return () => {
@@ -189,7 +189,7 @@ export class ObservableImpl<T extends TNonFunctionProperties<T>> implements IObs
}
/** 订阅指定字段变化 */
subscribeKey<K extends keyof T>(
public subscribeKey<K extends keyof T>(
keys: K | K[],
fn: TObservableKeyListener<T, K>,
options: { immediate?: boolean } = {}
@@ -214,7 +214,7 @@ export class ObservableImpl<T extends TNonFunctionProperties<T>> implements IObs
}
/** 批量更新状态 */
patch(values: Partial<T>): void {
public patch(values: Partial<T>): void {
for (const key in values) {
if (Object.prototype.hasOwnProperty.call(values, key)) {
const typedKey = key as keyof T
@@ -226,7 +226,7 @@ export class ObservableImpl<T extends TNonFunctionProperties<T>> implements IObs
}
/** 销毁 Observable 实例 */
dispose(): void {
public dispose(): void {
this.disposed = true
this.listeners.clear()
this.keyListeners.clear()
@@ -234,7 +234,7 @@ export class ObservableImpl<T extends TNonFunctionProperties<T>> implements IObs
}
/** 语法糖:返回一个可解构赋值的 Proxy */
toRefsProxy(): { [K in keyof T]: T[K] } {
public toRefsProxy(): { [K in keyof T]: T[K] } {
const self = this
return new Proxy({} as T, {
get(_, prop: string | symbol) {