import { default as BaseModel } from "./BaseModel.js";
export default class ControllerModel extends BaseModel {
    constructor(options) {
        super(options);
        this.m_parent = options.parent;
        this.m_events = new Jade.EventBus();
        this.onInit();
    }
    get parent() {
        return this.m_parent;
    }
    onInit() {
    }
    onActivate() {
    }
    activate() {
        this.onActivate();
    }
    commit() {
        this.m_events.publish("___commit___");
    }
    toJSON() {
        return {};
    }
    onValueChanged(arg1, handler) {
        let names = _.isArray(arg1) ? arg1 : [arg1];
        names.forEach(name => {
            this.m_events.subscribe(name, handler);
        });
    }
    valueChanged(args) {
        this.m_events.publish(args.name, args);
    }
    onCommit(handler) {
        return this.m_events.subscribe("___commit___", handler);
    }
}
