Skip to content

Instantly share code, notes, and snippets.

@calamarico
Created July 30, 2015 12:18
Show Gist options
  • Save calamarico/fe228afbed495680fa97 to your computer and use it in GitHub Desktop.
Save calamarico/fe228afbed495680fa97 to your computer and use it in GitHub Desktop.
function instrumentedWatch(watchExpression, listener, objectEquality) {
// jshint validthis:true
var watchTimingSet = false;
if (!watchTiming) {
// Capture watch timing (and its key) once, before we descend in $$watchDelegates.
watchTiming = createTiming(formatExpression(watchExpression));
watchTimingSet = true;
}
if (watchExpression && watchExpression.indexOf && watchExpression.indexOf('|') !== -1) {
console.log('bingo');
}
originalWatch.call(this, watchExpression, listener, objectEquality);
// try {
// if (angular.isString(watchExpression)) {
// if (!$parse) {
// angular.injector(['ng']).invoke(['$parse', function(parse) {$parse = parse;}]);
// }
// watchExpression = $parse(watchExpression);
// }
// if (watchExpression && watchExpression.$$watchDelegate) {
// return originalWatch.call(this, watchExpression, listener, objectEquality);
// } else {
// return originalWatch.call(
// this, wrapExpression(watchExpression, watchTiming, 'watch', true, false),
// wrapListener(listener, watchTiming), objectEquality);
// }
// } finally {
// if (watchTimingSet) watchTiming = null;
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment