Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if dirty checking is use?

I have some complex screen in my Aurelia app and I would like to check easily if some bindings are dirty checked. I can add console.log in all my property getter and check when it is called but it's not easy.

Ideally I would like to get in the console the observer strategy used by each binding, but I didn't find where to plug to add this log.

Thanks

like image 931
Valentin B. Avatar asked Mar 30 '16 18:03

Valentin B.


People also ask

How do you know if a form is dirty?

if you want to see if the form is dirty you should check the viewModel in kendo way sample. basically I've created a viewModel which is impements the ObservableObject interface and has a two way binding with the form's container.

What is dirty checking?

Dirty checking is a simple process that boils down to a very basic concept: It checks whether a value has changed that hasn't yet been synchronized across the app. Our Angular app keeps track of the values of the current watches.

How can we avoid dirty checking in hibernate?

A solution to this problem is to change the default configuration of FlushMode from auto to manual by setting FlushMode. MANUAL . In this way the dirty check mechanism will stop causing the aforementioned synchronization. Although the Session is only ever flushed when Session.

How is dirty checking implemented in hibernate?

It is simple-- when you load/get entity object by id and then set its new field values by setter method and close session without calling update() method. then hibernate automatically update the changed value in the table without affecting other fields. and at the same time entity object is in dirty state.


1 Answers

You can override DirtyCheckProperty's subscribe method to add logging:

import {DirtyCheckProperty} from 'aurelia-binding';
import * as LogManager from 'aurelia-logging';

const logger = LogManager.getLogger('my-app');

DirtyCheckProperty.prototype.standardSubscribe = DirtyCheckProperty.prototype.subscribe;
DirtyCheckProperty.prototype.subscribe = function(context, callable) {
  this.standardSubscribe(context, callable);

  logger.warn(`'${this.obj.constructor.name}.${this.propertyName}' is being dirty checked`, this.obj);
}

The messages would look like this in the console:

console

Here's a running example app:

https://gist.run/?id=2c863d48a2a711b8c5f93df2bb7c4a3b

like image 186
Jeremy Danyow Avatar answered Oct 24 '22 12:10

Jeremy Danyow