diff --git a/doric-js/bundle/doric-lib.es5.js b/doric-js/bundle/doric-lib.es5.js index f22ffdd2..9e792a00 100644 --- a/doric-js/bundle/doric-lib.es5.js +++ b/doric-js/bundle/doric-lib.es5.js @@ -3476,6 +3476,7 @@ var VMPanel = /** @class */ (function (_super) { VMPanel.prototype.build = function (root) { this.vh = new (this.getViewHolderClass()); this.vm = new (this.getViewModelClass())(this.getState(), this.vh); + this.vm.context = this.context; this.vm.attach(root); }; return VMPanel; diff --git a/doric-js/bundle/doric-lib.js b/doric-js/bundle/doric-lib.js index d15e4094..8528b801 100644 --- a/doric-js/bundle/doric-lib.js +++ b/doric-js/bundle/doric-lib.js @@ -2695,6 +2695,7 @@ class VMPanel extends Panel { build(root) { this.vh = new (this.getViewHolderClass()); this.vm = new (this.getViewModelClass())(this.getState(), this.vh); + this.vm.context = this.context; this.vm.attach(root); } } diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index 5f96efe6..93c03f9b 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -4184,6 +4184,7 @@ class VMPanel extends Panel { build(root) { this.vh = new (this.getViewHolderClass()); this.vm = new (this.getViewModelClass())(this.getState(), this.vh); + this.vm.context = this.context; this.vm.attach(root); } } diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 1d4c80b6..f336bc63 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -144,11 +144,13 @@ declare module 'doric/lib/src/ui/panel' { declare module 'doric/lib/src/pattern/mvvm' { import { Group } from "doric/lib/src/ui/view"; import { Panel } from "doric/lib/src/ui/panel"; + import { BridgeContext } from "doric/lib/src/runtime/global"; export abstract class ViewHolder { abstract build(root: Group): void; } export type Setter = (state: M) => void; export abstract class ViewModel { + context: BridgeContext; constructor(obj: M, v: V); getState(): M; getViewHolder(): V; diff --git a/doric-js/lib/src/pattern/mvvm.d.ts b/doric-js/lib/src/pattern/mvvm.d.ts index 78bfe5bd..3da9340c 100644 --- a/doric-js/lib/src/pattern/mvvm.d.ts +++ b/doric-js/lib/src/pattern/mvvm.d.ts @@ -1,10 +1,12 @@ import { Group } from "../ui/view"; import { Panel } from "../ui/panel"; +import { BridgeContext } from "../runtime/global"; export declare abstract class ViewHolder { abstract build(root: Group): void; } export declare type Setter = (state: M) => void; export declare abstract class ViewModel { + context: BridgeContext; private state; private viewHolder; constructor(obj: M, v: V); diff --git a/doric-js/lib/src/pattern/mvvm.js b/doric-js/lib/src/pattern/mvvm.js index de44bf6f..dfb5cd5f 100644 --- a/doric-js/lib/src/pattern/mvvm.js +++ b/doric-js/lib/src/pattern/mvvm.js @@ -29,6 +29,7 @@ export class VMPanel extends Panel { build(root) { this.vh = new (this.getViewHolderClass()); this.vm = new (this.getViewModelClass())(this.getState(), this.vh); + this.vm.context = this.context; this.vm.attach(root); } } diff --git a/doric-js/src/pattern/mvvm.ts b/doric-js/src/pattern/mvvm.ts index d616fd13..d007a8a6 100644 --- a/doric-js/src/pattern/mvvm.ts +++ b/doric-js/src/pattern/mvvm.ts @@ -15,6 +15,7 @@ */ import { Group } from "../ui/view" import { Panel } from "../ui/panel" +import { BridgeContext } from "../runtime/global" export abstract class ViewHolder { abstract build(root: Group): void @@ -23,6 +24,7 @@ export abstract class ViewHolder { export type Setter = (state: M) => void export abstract class ViewModel { + context!: BridgeContext private state: M private viewHolder: V @@ -57,10 +59,8 @@ export abstract class ViewModel { export type ClassType = new (...args: any) => T export abstract class VMPanel extends Panel { - private vm?: ViewModel private vh?: V - abstract getViewModelClass(): ClassType> abstract getState(): M @@ -74,6 +74,7 @@ export abstract class VMPanel extends Pa build(root: Group): void { this.vh = new (this.getViewHolderClass()) this.vm = new (this.getViewModelClass())(this.getState(), this.vh) + this.vm.context = this.context this.vm.attach(root) } }