2

I am trying to debug performance issues with my app which loads long list. Each item in list has a lot of bindings. I changed bindings to use the new format prefixed with :: . I counted my watch for 12 items, it came as 887 same number as before.

I then added bindonce (pasvaz bindonce library) to one field in the list and the number of watches came down from 887 to 667. I was under the impression that both of them are equivalent. What am I doing wrong? I used this method to check the number of watchers on the page.

Update : Angular batarang still shows one-time binding in the performance tab

{{::arr.length}} 7% 60.12ms

technically,it shouldn't be coming up in the list right ?

Example The Watch Expressions Tab in Angular JS Batarang

Update 2 : plnkr.co/edit/khB1hkEEvXfIQrETJ2TT?p=info . I made a plunkr.I would like to know the number of watches that Angular will put for this ? And how would bindonce will be different

Community
  • 1
  • 1
Abhik
  • 1,920
  • 7
  • 27
  • 50
  • The script for counting watchers is not working in a fiddle – Abhik Jun 16 '14 at 20:16
  • I meant your app's code. – gkalpak Jun 16 '14 at 20:19
  • This has no relation to my app code. What I want to know are the difference between the too. Also I saw that in batarang the one time binding taking up memory . – Abhik Jun 16 '14 at 20:58
  • 1
    It might be too broad a topic to talk about the differences between Angular's `::` and `BindOnce`. If you provide a specific issue/usecase, it might be easier to answer. – gkalpak Jun 16 '14 at 21:01
  • http://plnkr.co/edit/khB1hkEEvXfIQrETJ2TT?p=info . I made a plunkr.I would like to know the number of watches that Angular will put for this ? And how would bindonce will be different – Abhik Jun 16 '14 at 21:10
  • In your plunkr there should be 2 watchers (1 for the input, 1 for the `{{item}}`, 0 for the `{{::item}}` once it is set). Angular's `::` and `BindOnce` should behave the same in this simple usecase. Post a piece of code (an **[SSCCE](http://sscce.org)** preferrably) that demonstrates what you describe. – gkalpak Jun 16 '14 at 21:18
  • Yes, Then why does {{::item}} show up on Angular Js batarang in watch expressions ? – Abhik Jun 16 '14 at 21:25
  • I have put up an image showing what I am seeing in my Angular JS batarang . As far I understand in no reason should I see a "one-time-binded" in the batarang watch expression – Abhik Jun 16 '14 at 21:30
  • `::` (as `BindOnce`) does use a watch, until the expression gets defined. What you see is the time spent on those initial watches before the exressions evaluated to something non-undefined. If you keep interacting with the app, the total time for `::` expressions should remain constant and the percentage should decrease. – gkalpak Jun 16 '14 at 21:58
  • You can get the number of watches for a particular scope (and its children, siblings..) like the one here (click on the button to see number of watches beside it) http://plnkr.co/edit/bqCAvqZBZG2UDyokWi0e?p=preview – javaCity Jun 16 '14 at 22:14
  • @ExpertSystem by the above method your answer is wrong . Shouldn't it be showing 2 ? – Abhik Jun 16 '14 at 22:41
  • @Abhik: Not sure what you mean. What method ? What answer ? Why wrong ? What 2 ? I totally lost you... – gkalpak Jun 17 '14 at 05:01
  • 1
    @Abhik: If you mean that you expected havaCity's plunkr to display `2`, it is displaying `3` because of the extra `{{numberOfWatches}}` binding. Alas 2 watches for your code + 1 for javaCity's extra code. – gkalpak Jun 17 '14 at 05:10
  • It seems batarang is cancelling the effect of lazy one-time binding. – Jonathan Maim Aug 13 '14 at 11:00

0 Answers0