Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check if the current data set is "dirty"?

Tags:

vue.js

How do I check if the current data set is dirty?

I want to do a quick check before posting the data. Given the following code snippet as an example:

save: function(e) {
    if(~~insert dirty check here~~) {
        $.ajax(e.currentTarget.action, {
            type: this.method,
            data: {
                _method: this.method,
                _token: this.token,
                data: JSON.stringify(this.card_data)
            }
        }).done($.proxy(function(content) {
            this.card_data = content;
            this.mode = 'view';
        }, this));
    }

}
like image 958
Chris Avatar asked Oct 25 '15 13:10

Chris


1 Answers

It doesn't seem like Vue.js uses any dirty checking.

Vue.js is able to deliver the plain JavaScript object syntax without resorting to dirty checking by using Object.defineProperty, which is an ECMAScript 5 feature. It only works on DOM elements in IE8 and there's no way to polyfill it for JavaScript objects.

Source: https://github.com/vuejs/vue/wiki/FAQ

Vue.js has better performance because it doesn't use dirty checking.

Source: https://github.com/vuejs/vue/issues/96#issuecomment-35052704

like image 60
Thomas Kim Avatar answered Sep 22 '22 03:09

Thomas Kim