bindonce icon indicating copy to clipboard operation
bindonce copied to clipboard

bindonce repeater

Open elemoine opened this issue 11 years ago • 20 comments

ng-repeat registers a collection watcher (with $watchCollection), which can be costly, especially when considering ng-repeat based recursive directives (as in http://jsfiddle.net/n8dPm/).

I was wondering if a bindonce type repeater would make sense. That repeater would wait for the collection to be there, but wouldn't shallow-watch the collection.

Not sure it makes sense. Feel free to close this issue if it doesn't. Thanks.

elemoine avatar Jul 20 '13 08:07 elemoine

Yes it makes sense, I've been thinking a lot about creating bo-repeat in order to get rid of the watcher but not only for that, a repeater uses one watcher ($watchCollection as you said) but what makes it expensive in term of performances is the creation of a child scope for each item, in case of large set can be costly. Now bo-* fields can live without child scopes because once the item is drawn even if the scope change it is no longer bound with the scope, but if you use any ng-* field inside the bo-repeater you immediately run into scope issues. However we can try to deal with this is it is necessary...

Pasvaz avatar Jul 23 '13 06:07 Pasvaz

:+1:. I found many cases in my websites where I'd need to use that.

akarelas avatar Sep 25 '13 18:09 akarelas

:+1: It would be one of the most useful cases, especially when grids loop through rows and columns.

adamkdean avatar Nov 26 '13 11:11 adamkdean

:+1:

FGRibreau avatar Nov 26 '13 15:11 FGRibreau

:+1:

mendelk avatar Jan 13 '14 16:01 mendelk

:+1:

evilaliv3 avatar Jan 25 '14 10:01 evilaliv3

I need this in my life. But mostly, I need it in my code... Pasvaz, any time you spend towards making this a reality would be much appreciated :)

MWallenberg avatar Feb 15 '14 20:02 MWallenberg

Hi @MWallenberg, this will be the next step, right now I'm focusing on the rebind feature, when the new binding system will work flawlessy it shouldn't be a problem to implement a repeater.

Pasvaz avatar Feb 16 '14 10:02 Pasvaz

+1, would be awesome to have

pgayvallet avatar Feb 17 '14 13:02 pgayvallet

:+1:

mparpaillon avatar Mar 09 '14 17:03 mparpaillon

:+1:

philippzentner avatar Apr 21 '14 09:04 philippzentner

:+1: looking forward to this feature

schickling avatar May 09 '14 16:05 schickling

:+1:

fidoboy avatar May 09 '14 16:05 fidoboy

+1

steve8708 avatar Jul 25 '14 18:07 steve8708

I believe that Angular 1.3 solves this problem, like so:

<li ng-repeat="item in ::items">{{::item.name}}</li>

akarelas avatar Aug 06 '14 17:08 akarelas

akarelas, I looked at Angular 1.3 documentation and don't see any mention of the syntax you posted. Where do get that from?

michael-wynn avatar Aug 23 '14 01:08 michael-wynn

@michael-wynn I don't know where I learned it from (maybe from the Changelog of Angular 1.3) but it works.

akarelas avatar Aug 23 '14 08:08 akarelas

@michael-wynn @akarelas https://docs.angularjs.org/guide/expression#one-time-binding

lorenzhs avatar Aug 23 '14 10:08 lorenzhs

Thank you!

From: Lorenz Hübschle-Schneider [mailto:[email protected]] Sent: Saturday, August 23, 2014 3:45 AM To: Pasvaz/bindonce Cc: michael-wynn Subject: Re: [bindonce] bindonce repeater (#10)

@michael-wynn https://github.com/michael-wynn @akarelas https://github.com/akarelas https://docs.angularjs.org/guide/expression#one-time-binding

— Reply to this email directly or view it on GitHub https://github.com/Pasvaz/bindonce/issues/10#issuecomment-53149458 . https://github.com/notifications/beacon/4787565__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNDQwOTkyMiwiZGF0YSI6eyJpZCI6MTM5NjQxOTF9fQ==--355d83e1f1550465505a3205688358a9af8b503f.gif

michael-wynn avatar Aug 23 '14 23:08 michael-wynn

In fact, I replaced bindonce with Angular one-time bindings in Glowing Bear yesterday: https://github.com/glowing-bear/glowing-bear/pull/418

It started with adding :: to ng-repeat statements, but it soon emerged that we could drop bindonce altogether, as we're using angular 1.3 beta in production :bomb: Now we have one less dependency (even if it was only 6.5k minified). Sorry to abandon you ;)

lorenzhs avatar Aug 24 '14 10:08 lorenzhs