DevExpress / devextreme-angular-template

Responsive Application Layout Templates​ based on DevExtreme Angular Components
https://js.devexpress.com/
MIT License
119 stars 48 forks source link

Angular Change Detection #165

Closed FonsecaDevs closed 2 years ago

FonsecaDevs commented 2 years ago

Hi, When using functions instead variables on binds

eg: [file] side-navigation-menu.component.ts [sample]

private _items; get items() { console.error("ok"); if (!this._items) { this._items = navigation.map((item) => { if(item.path && !(/^\//.test(item.path))){ item.path = /${item.path}; } return { ...item, expanded: !this._compactMode } }); }

return this._items;

}

when every click in body trigger this function many times, maybe when is low process is good, but if for example big menu maybe cause performance issue.

https://gyazo.com/c7441fdde966d768ff1a855bfd815d11

possible quickie fix

private _items; items = this.getitems(); getitems() { console.error("ok") if (!this._items) { this._items = navigation.map((item) => { if(item.path && !(/^\//.test(item.path))){ item.path = /${item.path}; } return { ...item, expanded: !this._compactMode } }); }

return this._items;

}

Thank you