Skip to content

Frozen data models #662

@paleo

Description

@paleo

I suggest to allow frozen trees into a data model. Example:

function makeSubModel(val) {
    return Object.freeze({
        key1: Object.freeze({
            key2: val
        })
    });
}
var data = {
    frozenSubModel: makeSubModel('init')
}
new Vue({
    // …,
    data: data
});
data.frozenSubModel = makeSubModel('changed');

The current version rejects the frozen model: "Cannot define property:__ob__, object is not extensible." But frozen objects don't need to be observed.


I have several instances of Vue that share the same template. Is there a means to compile the template once?

My current code:

var myTpl = '<div>…</div>';
var vm1 = new Vue({
    // …,
    template: myTpl
});
var vm2 = new Vue({
    // …,
    template: myTpl
});

I would like to have:

var compiledTpl = Vue.compile('<div>…</div>');
var vm1 = new Vue({
    // …,
    template: compiledTpl
});
var vm2 = new Vue({
    // …,
    template: compiledTpl
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions