feat: add apply function on Ref
This commit is contained in:
@@ -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() {
|
||||
|
@@ -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> {
|
||||
|
Reference in New Issue
Block a user