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

use trackBy to prevent full DOM refresh and performance improvement #444

Closed
volser opened this issue Jan 29, 2018 · 3 comments
Closed

use trackBy to prevent full DOM refresh and performance improvement #444

volser opened this issue Jan 29, 2018 · 3 comments

Comments

@volser
Copy link

volser commented Jan 29, 2018

[ ] Bug report 
[x] Feature request
[ ] Support request => Please do not submit a support request here, please ask on https://stackoverflow.com/

I noticed, when I d&d events DOM are totally refreshed, maybe use trackBy to prevent full DOM refresh and performance improvement?
http://recordit.co/yC4LF8jqFT

@mattlewis92
Copy link
Owner

I've considered this before as well. The problem is that events have no unique id property to track by, do you have any idea if the value returned by the track by function can be an object i.e. the event itself?

@volser
Copy link
Author

volser commented Jan 29, 2018

I believe, by default angular uses object to identify item.

default:
const trackByIdentity = (index: number, item: any) => item;
https://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/core/src/change_detection/differs/default_iterable_differ.ts

So you can add id property (optional) to event object, like fullcalendar did
https://fullcalendar.io/docs/event_data/Event_Object/

and (index: number, item: any) => item.id ? item.id : item;

@mattlewis92
Copy link
Owner

Please give 0.23.3 a go, everything should now use ngFor's. Thanks for the suggestion! 😄

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

Successfully merging a pull request may close this issue.

2 participants