Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a772b94

Browse files
committed
chore(benchmarks): add $watchCollection tests
1 parent 423acc2 commit a772b94

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

benchmarks/parsed-expressions-bp/app.js

+15
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ app.directive('bmPeWatch', function() {
2929
};
3030
});
3131

32+
//Executes the specified expression as a collection watcher
33+
app.directive('bmPeWatchCollection', function() {
34+
return {
35+
restrict: 'A',
36+
compile: function($element, $attrs) {
37+
$element.text($attrs.bmPeWatchCollection);
38+
return function($scope, $element, $attrs) {
39+
$scope.$watchCollection($attrs.bmPeWatchCollection, function(val) {
40+
$element.text(val);
41+
});
42+
};
43+
}
44+
};
45+
});
46+
3247
app.controller('DataController', function($scope, $rootScope) {
3348
var totalRows = 10000;
3449

benchmarks/parsed-expressions-bp/main.html

+27
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
<input type="radio" ng-model="expressionType" value="arrayLiterals" id="arrayLiterals">
6161
<label for="arrayLiterals">Array Literals</label>
6262
</li>
63+
64+
<li>
65+
<input type="radio" ng-model="expressionType" value="watchCollection" id="watchCollection">
66+
<label for="watchCollection">$watchCollection</label>
67+
</li>
68+
69+
<li>
70+
<input type="radio" ng-model="expressionType" value="watchCollectionLiterals" id="watchCollectionLiterals">
71+
<label for="watchCollectionLiterals">$watchCollection Literals</label>
72+
</li>
6373
</ul>
6474

6575
<!--
@@ -220,6 +230,23 @@
220230
<span bm-pe-watch="[0, 1, 2, rowIdx]"></span>
221231
<span bm-pe-watch="[0, 1, 2, 3, rowIdx]"></span>
222232
</li>
233+
234+
<li ng-switch-when="watchCollection" ng-repeat="(rowIdx, row) in data">
235+
<span bm-pe-watch-collection="data"></span>
236+
<span bm-pe-watch-collection="row.keys"></span>
237+
<span bm-pe-watch-collection="thisProbablyDoesntHaveAValue"></span>
238+
</li>
239+
240+
<li ng-switch-when="watchCollectionLiterals" ng-repeat="(rowIdx, row) in ::data">
241+
<span bm-pe-watch-collection="[rowIdx, row]"></span>
242+
<span bm-pe-watch-collection="[rowIdx, row, num0, str0, date0, obj, g, h, i, j, k, l, m, n, o, p]"></span>
243+
<span bm-pe-watch-collection="{a: rowIdx, b: row, c: num0, d: str0, e: date0, f: obj, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p}"></span>
244+
245+
<!-- primitive/valueOf-compatible -->
246+
<span bm-pe-watch-collection="[rowIdx, row]"></span>
247+
<span bm-pe-watch-collection="[rowIdx, num0, str0, date0, date1, h, i, j, k, l, m, n, o, p]"></span>
248+
<span bm-pe-watch-collection="{a: rowIdx, c: num0, d: str0, e: date0, g: date1, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p}"></span>
249+
</li>
223250
</ul>
224251
</div>
225252
</div>

0 commit comments

Comments
 (0)