milo

Expose Model class methods on ModelFacet

Model.useWith(ModelFacet, 'm');


function ModelFacet$init() {
    this.m = new Model(this.config.data, this);
    ComponentFacet.prototype.init.apply(this, arguments);
    // this.m.proxyMethods(this); // Creates model's methods directly on facet
}

ModelFacet$getState

function
 ModelFacet$getState() 

ModelFacet instance method
Called by Component.prototype.getState to get facet's state
Simply returns model data

function ModelFacet$getState() {
    var modelValue = this.m.get();
    if (typeof modelValue == 'object')
        modelValue = _.deepClone(modelValue);
    return { state: modelValue };
}

ModelFacet$setState

function
 ModelFacet$setState() 

Option name Type Description
state Object

data to set on facet's model

ModelFacet instance method
Called by Component.prototype.setState to set facet's state
Simply sets model data

function ModelFacet$setState(state) {
    return this.m.set(state.state);
}


function ModelFacet$_createMessenger() { // Called by inherited init
    this._messenger = this.m._messenger;
}


function ModelFacet$destroy() {
    this.m.destroy();
    ComponentFacet.prototype.destroy.apply(this, arguments);
}