optimize the definition of VMPanel
This commit is contained in:
parent
ac152df6f0
commit
9a1a8be5ae
7
doric-js/index.d.ts
vendored
7
doric-js/index.d.ts
vendored
@ -1266,12 +1266,11 @@ declare module 'doric/lib/src/pattern/mvvm' {
|
|||||||
abstract onAttached(state: M, vh: V): void;
|
abstract onAttached(state: M, vh: V): void;
|
||||||
abstract onBind(state: M, vh: V): void;
|
abstract onBind(state: M, vh: V): void;
|
||||||
}
|
}
|
||||||
export type ViewModelClass<M, V extends ViewHolder> = new (m: M, v: V) => ViewModel<M, V>;
|
export type ClassType<T> = new (...args: any) => T;
|
||||||
export type ViewHolderClass<V> = new () => V;
|
|
||||||
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
||||||
abstract getViewModelClass(): ViewModelClass<M, V>;
|
abstract getViewModelClass(): ClassType<ViewModel<M, V>>;
|
||||||
abstract getState(): M;
|
abstract getState(): M;
|
||||||
abstract getViewHolderClass(): ViewHolderClass<V>;
|
abstract getViewHolderClass(): ClassType<V>;
|
||||||
getViewModel(): ViewModel<M, V> | undefined;
|
getViewModel(): ViewModel<M, V> | undefined;
|
||||||
build(root: Group): void;
|
build(root: Group): void;
|
||||||
}
|
}
|
||||||
|
7
doric-js/lib/src/pattern/mvvm.d.ts
vendored
7
doric-js/lib/src/pattern/mvvm.d.ts
vendored
@ -15,14 +15,13 @@ export declare abstract class ViewModel<M extends Object, V extends ViewHolder>
|
|||||||
abstract onAttached(state: M, vh: V): void;
|
abstract onAttached(state: M, vh: V): void;
|
||||||
abstract onBind(state: M, vh: V): void;
|
abstract onBind(state: M, vh: V): void;
|
||||||
}
|
}
|
||||||
export declare type ViewModelClass<M, V extends ViewHolder> = new (m: M, v: V) => ViewModel<M, V>;
|
export declare type ClassType<T> = new (...args: any) => T;
|
||||||
export declare type ViewHolderClass<V> = new () => V;
|
|
||||||
export declare abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
export declare abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
||||||
private vm?;
|
private vm?;
|
||||||
private vh?;
|
private vh?;
|
||||||
abstract getViewModelClass(): ViewModelClass<M, V>;
|
abstract getViewModelClass(): ClassType<ViewModel<M, V>>;
|
||||||
abstract getState(): M;
|
abstract getState(): M;
|
||||||
abstract getViewHolderClass(): ViewHolderClass<V>;
|
abstract getViewHolderClass(): ClassType<V>;
|
||||||
getViewModel(): ViewModel<M, V> | undefined;
|
getViewModel(): ViewModel<M, V> | undefined;
|
||||||
build(root: Group): void;
|
build(root: Group): void;
|
||||||
}
|
}
|
||||||
|
@ -54,20 +54,19 @@ export abstract class ViewModel<M extends Object, V extends ViewHolder> {
|
|||||||
|
|
||||||
abstract onBind(state: M, vh: V): void
|
abstract onBind(state: M, vh: V): void
|
||||||
}
|
}
|
||||||
export type ViewModelClass<M, V extends ViewHolder> = new (m: M, v: V) => ViewModel<M, V>
|
|
||||||
|
|
||||||
export type ViewHolderClass<V> = new () => V
|
export type ClassType<T> = new (...args: any) => T
|
||||||
|
|
||||||
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
|
||||||
|
|
||||||
private vm?: ViewModel<M, V>
|
private vm?: ViewModel<M, V>
|
||||||
private vh?: V
|
private vh?: V
|
||||||
|
|
||||||
abstract getViewModelClass(): ViewModelClass<M, V>
|
abstract getViewModelClass(): ClassType<ViewModel<M, V>>
|
||||||
|
|
||||||
abstract getState(): M
|
abstract getState(): M
|
||||||
|
|
||||||
abstract getViewHolderClass(): ViewHolderClass<V>
|
abstract getViewHolderClass(): ClassType<V>
|
||||||
|
|
||||||
getViewModel() {
|
getViewModel() {
|
||||||
return this.vm
|
return this.vm
|
||||||
|
Reference in New Issue
Block a user