Skip to content

Can I $watch whole $data but except some properties? #350

@Alexorz

Description

@Alexorz

See the code here:

new Vue({
    el: '#x',
    data: {
        prop1 : '',
        prop2 : '',
        ...
        result : ''
    },
    ready: function(){
        this.$watch('$data', function(){
            this.load(function( xx ){
                // # This will cause '$data change' again, then do 'load' again, infinity looping...
                this.result = xx;
                // /
                // So, can I watch the whole $data but except the 'result'?
            });
        });
    },
    methods: {
        load: function( callback ){
            var self = this;
            doSomeAsync(function( xx ){
                callback.call(self, xx);
            });
        }
    }
});

Did I use it in the right way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions