-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
Re-evaluation of translate pipes if ChangeDetectionStrategy.OnPush is set #33
Comments
I'm not expert enough in Angular 2 to know the right thing to do here. Do you have an article somewhere explaining the different change detection strategies ? |
I am just starting to figure it out as well and the documentation is not very good at this point of time. I guess the best articles to start are: Give me some time and I will prepare a example for the case. |
Thanks, I'll look at them this week end |
I have a hard time to get this running for an example. Do you have a working jsfiddle or plunker with ng2-translate? In the meantime I tested #31 and it perfectly fixes my issue. If I use directives instead of pipes in my application, everything gets updated perfectly even if OnPush is used. |
It look like we might need to write a sanitization library for ng2 |
Hey @PascalPrecht any idea on how to make the pipe work with OnPush ? |
I don't know if there's any event system implemented in ng2-translate yet, but if there's something like a translate service, it could expose an observable which fires when the languages changes. Then the pipe could subscribe to that service and it could use the changedetector ref to mark the path til root to be checked. |
Thanks @PascalPrecht, it turns out that you can inject a |
Honestly ngxtranslate doesn't play well with OnPush change detection, for every component which uses translate pipe you has to write a lot of same boilerplate code, so think twice before use this lib if you want use it alongside with OnPush. Has to write some helper pipe to workaround this https://gist.github.com/baio/e1da9826806ae3bad639b194958cbdcc |
Hi,
I am currently try to use
ChangeDetectionStrategy.OnPush
in all my components. That means, that all bindings are not checked if the state of my application stays the same. Thats great but it means that all translate pipes are not getting re-evaluated if I change the current language.I think It may possible to wrap the pipe into an own directive that listens to the
onLangChange
event and invalidates itself.Do you have any Ideas?
The text was updated successfully, but these errors were encountered: