Description
Issue type
I'm submitting a ... (check one with "x")
- bug report
- feature request
- question about the decisions made in the repository
Issue description
Current behavior:
Its seems that change detection is called way too many times on most pages. With the starter kit, the NbLoginComponent
causes method getConfigValue()
to be called roughly 350 times in Safari and 230 in Chrome. When the page takes a while to load in Chrome, the counter goes up to 5000+ calls after a few seconds.
When removing pace-js
(loading bar at the top), the counter drops down to 20 on both Safari and Chrome, yet acceptable but still a bit high IMO.
Expected behavior:
Considering that getConfigValue()
is used twice in the NbLoginComponent
template, and also considering that change detection runs twice as more in Angular CLI's dev mode, I would still expect the number of calls to be around 2-6, not ~90 times (350/2/2). I have tried a production build and the number drops (as expected) to roughly half that amount, but still remains too high.
Steps to reproduce:
- Clone the starter kit of this repository.
- Create a login component identical to Nebular's default
NbLoginComponent
. - Change the following lines:
getConfigValue(key: string): any {
return getDeepFromObject(this.config, key, null);
}
to
private count: number = 0;
getConfigValue(key: string): any {
this.count++;
console.log(this.count);
return getDeepFromObject(this.config, key, null);
}
- Start the application and look at the console:
And without pace-js
:
Related code:
Other information:
npm, node, OS, Browser
node v7.1.0
nom v4.6.1
Angular, Nebular
ngx-admin v2.1.0