Giter Site home page Giter Site logo

Comments (10)

ocombe avatar ocombe commented on May 18, 2024

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 ?
And an example app that uses OnPush ?

from core.

hpop avatar hpop commented on May 18, 2024

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:
http://victorsavkin.com/post/110170125256/change-detection-in-angular-2
http://victorsavkin.com/post/137821436516/managing-state-in-angular-2-applications

Give me some time and I will prepare a example for the case.

from core.

ocombe avatar ocombe commented on May 18, 2024

Thanks, I'll look at them this week end

from core.

hpop avatar hpop commented on May 18, 2024

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.

from core.

sclausen avatar sclausen commented on May 18, 2024

@hpop but be aware, that you should be careful with html injection, since no sanitization will be performed.
I did a little bit of research because of @ocombe s concerns in #31, but I didn't found any lightweight solution for this problem.

from core.

ocombe avatar ocombe commented on May 18, 2024

It look like we might need to write a sanitization library for ng2

from core.

ocombe avatar ocombe commented on May 18, 2024

Hey @PascalPrecht any idea on how to make the pipe work with OnPush ?

from core.

0x-r4bbit avatar 0x-r4bbit commented on May 18, 2024

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.

from core.

ocombe avatar ocombe commented on May 18, 2024

Thanks @PascalPrecht, it turns out that you can inject a ChangeDetectorRef in a pipe (I found out by reading the AsyncPipe source code). It should work now !

from core.

baio avatar baio commented on May 18, 2024

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

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.