Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation needed on quick-repeat-list #1

Closed
djsmith42 opened this issue Oct 24, 2013 · 17 comments
Closed

Documentation needed on quick-repeat-list #1

djsmith42 opened this issue Oct 24, 2013 · 17 comments

Comments

@djsmith42
Copy link

What is quick-repeat-list intended for? Does each of my quick-ng-repeat instances need a unique quick-repeat-list value?

@allaud
Copy link
Owner

allaud commented Oct 24, 2013

@djsmith42
quickRepeatList attribute contains a key name for hash storing $watch callbacks. While linking a new directive, we store a reference to $watch callback in that hash using quickRepeatList attribute:

https://github.com/allaud/quick-ng-repeat/blob/master/quick-ng-repeat.js#L126

And the next time we need to refresh our list we don't need to wait for digest cycle (which is usually heavy, moreover it is done synchronously). Instead we can call this callback manually and asynchronously:

https://github.com/allaud/quick-ng-repeat/blob/master/example/js/main.js#L53

This allows us to make a heavy list render without blocking ui (and many more things, redraw some lists eventually for example, without redrawing the whole application).

So, the answer to your questing is - yes, most of the time you should use uniq names for that attribute. But I also can imagine some rare situations, when you need to replace one watcher callback with another.

@viktor-evdokimov
Copy link

Why wouldn't you generate unique one yourself if you need it pretty much every time ?

@allaud
Copy link
Owner

allaud commented Nov 20, 2013

@ojosdegris can you show the line of code you are speaking about?

@viktor-evdokimov
Copy link

@allaud I'm talking about quick-repeat-list directive, if it is better to have it every time, why not to generate unique value for it inside main directive ?

@allaud
Copy link
Owner

allaud commented Nov 20, 2013

@ojosdegris this the the code from html:

<div quick-ng-repeat="item in list" quick-repeat-list="items">

And this is the code from main.js , which contains some lazy-load logic:
https://github.com/allaud/quick-ng-repeat/blob/master/example/js/main.js#L53

 _.defer(quickRepeatList.items, $scope.list);

Specifying this name lets us to call from our code directly the list we want to operate with.

@justinmc
Copy link
Contributor

Then is there a way to supply this parameter dynamically?

I'm using quick-ng-repeat in a template that is used twice on the same page. Each instance needs a unique quick-repeat-list value, but because this is in a template, I can't supply two different values. If I use a scope variable like this it doesn't work: quick-repeat-list="[[ myQuickRepeatList ]]".

I realize that this parameter is necessary to refer to your list in javascript, but if I understand it correctly, the current setup still seems not ideal since it makes the plugin unusable in my case. If there's no way to supply quick-repeat-list dynamically, would it be better to store watch callbacks as an array of objects instead?

@lezhangxyz
Copy link

Agreed, this doesn't seem like something that the developer should need to set for 99% of cases. The directive should generate its own unique values unless explicitly specified.

@allaud
Copy link
Owner

allaud commented Nov 22, 2013

@justinmc @leisms accepted, the fix is coming

@allaud
Copy link
Owner

allaud commented Nov 22, 2013

@justinmc @leisms this addition should do the trick: b5e51ac

@justinmc
Copy link
Contributor

I think you mistyped from one copy of the quick-ng-repeat.js file to the other, check out my pull request.

After applying my pull request, this works for my use case. Thanks for the quick fix, I think it's much better like this! Now if you want to updated all instances, you can do something like this:

for (var key in quickRepeatList) { 
    quickRepeatList[key](mydata); 
}

This is really useful when you have multiple instances of quick-ng-repeat operating on the same data, especially when you're unable to assign unique quick-repeat-list parameters like I was.

@allaud
Copy link
Owner

allaud commented Nov 23, 2013

@justinmc yep, this was my mistake, thanks for contributing. I think, we can close this issue

@llchan
Copy link

llchan commented Dec 5, 2013

It may be worth mentioning here that issue #9 addresses some of the use cases mentioned in this thread. The change will give you more flexibility in naming dynamically-generated lists so you can retrieve them later.

@justinmc
Copy link
Contributor

@Adarsh456 Your code is missing!

@felix-d
Copy link

felix-d commented Jul 29, 2014

Quick-ng-repeat solved my issue with weird animated floating divs' behavior. Thanks!
http://stackoverflow.com/questions/25020731/racing-condition-with-dom-manipulation-ng-repeat-and-ng-class-animation-in-angu/25023599#25023599

@anilkhichar
Copy link

Thank a lot....It get me rid of performance issues in IE8.

@allaud allaud closed this as completed May 15, 2015
@yeddu
Copy link

yeddu commented Jul 10, 2015

I want to repeat the hierarchical data using quick-ng-repeat. How can i do this?

@alirizwan
Copy link

This is going on in: vm.FilteredData = $filter('filter')(vm.data, { CategoryId: vm.currentCategory.id });

All I get is one empty item. What could I be doing wrong here? Is it because of quick-repeat-list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants