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

[Bug] Translate Pipe's EventEmitter is not disposed of under RC1 #139

Closed
matthewrk opened this issue Jun 1, 2016 · 0 comments
Closed

[Bug] Translate Pipe's EventEmitter is not disposed of under RC1 #139

matthewrk opened this issue Jun 1, 2016 · 0 comments

Comments

@matthewrk
Copy link

I've noted that under RC1 my app becomes laggy as I switch between components, with further investigation I've identified the translate pipe as the culprit.

It seems that the EventEmitter that it uses to detect language changes is never disposed of (despite the ngOnDestroy implementation) and therefore as you move around your app the number of event listeners increases.

I've produced a simple plunker with a pipe implementation based on the ng2-translate one to demonstrate, instructions to reproduce are in the info pane.
http://plnkr.co/edit/TTgOOkhUvpz1d6C0qMgl?p=info

Reverting to Beta 17 does not show the same behaviour.

I have also produced a fixed version that uses a Subject rather than EventEmitter, and this one is disposed of correctly. This was following advice on the Angular2 Gitter (from @escardin specifically) about EventEmitter vs Subject, and that EventEmitter should only ideally be used with @output.

The implementation that uses Subject can be found here:
http://plnkr.co/edit/cTuZvvStG2QNrtEgu3pk?p=info

@ocombe ocombe closed this as completed in a95e585 Jun 22, 2016
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

No branches or pull requests

1 participant