How to check if dirty check is used?

I have a complex screen in an Aurelia application, and I would like to easily check if some bindings are dirty marked . I can add console.log to all my getter property and check when it gets called, but this is not easy.

Ideally, I would like to get the observer strategy used by each binding in the console, but I could not find where to connect to add this log.

thanks

+6
source share
1 answer

You can override the DirtyCheckProperty subscribe method to add a log:

 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); } 

Messages will look like this on the console:

console

An example application works here:

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

+10
source

All Articles