import { Panel } from "../ui/panel"; export class ViewHolder { } export class ViewModel { constructor(obj, v) { this.state = obj; this.viewHolder = v; } getState() { return this.state; } getViewHolder() { return this.viewHolder; } updateState(setter) { setter(this.state); this.onBind(this.state, this.viewHolder); } attach(view) { this.viewHolder.build(view); this.onAttached(this.state, this.viewHolder); this.onBind(this.state, this.viewHolder); } } export class VMPanel extends Panel { getViewModel() { return this.vm; } 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); } }