-
When an array changes, Angular re-renders the whole DOM tree. But if you use trackBy, Angular will know which element has changed and will only make DOM changes for that particular element.
<li *ngFor="let item of items;">{{ item }}</li>
/* in the template */
<li *ngFor="let item of items; trackBy: trackByFn">{{ item }}</li>
/* in the component */
trackByFn(index, item) {return item.id;}
Last active
January 15, 2019 18:53
-
-
Save darotar/6f918d2c9dbbc13c4d022dc7a56425a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) trackBy for loops | |
2) const vs let | |
3) RxJS pipeable operators | |
4) subscribing in template with async | |
5) Don't forget to destroy subscriptions (with takeUntil) | |
6) Use right *Map rxjs operator | |
7) If this is new route component, it must be lazy loaded | |
8) No subscriptions inside of subscriptions (use another rxjs operators) | |
9) Never use type 'any' | |
10) No magic numbers and no console.[anything] commands | |
11) Make component as dumb as possible | |
12) Don't repeat the same code and funcitons | |
13) Don't make logic in templates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment