MCPcopy
hub / github.com/angular-ui/ui-router / $watchCollectionAction

Function $watchCollectionAction

test/angular/1.4/angular.js:16088–16115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16086 }
16087
16088 function $watchCollectionAction() {
16089 if (initRun) {
16090 initRun = false;
16091 listener(newValue, newValue, self);
16092 } else {
16093 listener(newValue, veryOldValue, self);
16094 }
16095
16096 // make a copy for the next time a collection is changed
16097 if (trackVeryOldValue) {
16098 if (!isObject(newValue)) {
16099 //primitive
16100 veryOldValue = newValue;
16101 } else if (isArrayLike(newValue)) {
16102 veryOldValue = new Array(newValue.length);
16103 for (var i = 0; i < newValue.length; i++) {
16104 veryOldValue[i] = newValue[i];
16105 }
16106 } else { // if object
16107 veryOldValue = {};
16108 for (var key in newValue) {
16109 if (hasOwnProperty.call(newValue, key)) {
16110 veryOldValue[key] = newValue[key];
16111 }
16112 }
16113 }
16114 }
16115 }
16116
16117 return this.$watch(changeDetector, $watchCollectionAction);
16118 },

Callers

nothing calls this directly

Calls 3

listenerFunction · 0.70
isObjectFunction · 0.70
isArrayLikeFunction · 0.70

Tested by

no test coverage detected