feat: add apply function on Ref

This commit is contained in:
pengfei.zhou
2021-12-03 15:37:42 +08:00
committed by osborn
parent 1c1ca76782
commit 5aa20dbd6a
11 changed files with 53 additions and 1 deletions

View File

@@ -65,6 +65,8 @@ export type NativeViewModel = {
};
}
type RefType<T> = T extends Ref<infer R> ? R : never;
export class Ref<T extends View> {
private view?: T;
@@ -78,6 +80,12 @@ export class Ref<T extends View> {
}
return this.view
}
apply(config: Partial<RefType<this>>) {
if (this.view) {
this.view.apply(config)
}
}
}
export function createRef() {

View File

@@ -47,6 +47,8 @@ export type NativeViewModel = {
};
}
type RefType<T> = T extends Ref<infer R> ? R : never;
export class Ref<T extends View> {
private view?: T;
@@ -60,6 +62,12 @@ export class Ref<T extends View> {
}
return this.view
}
apply(config: Partial<RefType<this>>) {
if (this.view) {
this.view.apply(config)
}
}
}
export function createRef<T extends View>(): Ref<T> {