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

Window listener optimization #31

Merged
merged 1 commit into from
May 1, 2020
Merged

Conversation

mbilotta
Copy link

@mbilotta mbilotta commented Mar 1, 2020

Instead of always listening to window resize events, start/stop listening when ellipsis-resize-detection changes to/from window.

This change should improve performance when many instances of this directive are in use at the same time with detection strategies other than window.

Start/stop window resize event listening when resizeDetectionStrategy changes to/from "window"
@lentschi lentschi merged commit 96a3caf into lentschi:master May 1, 2020
@lentschi
Copy link
Owner

lentschi commented May 1, 2020

Thanks @mbilotta !
... and sorry that it took me so long to merge. It's now published as version 2.2.2.

At first, I thought there should be hardly any performance impact by the HostListener as it didn't run any code when not running with the window change detection strategy.
It turns out though, that whenever someone was resizing the window this caused ngAfterViewChecked to be run in every component of the app. (This is by angular's design.)

So, if there is a lot of code in the consuming app's ngAfterViewChecked methods, your change should really boost performance!

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 this pull request may close these issues.

None yet

2 participants