GithubHelp home page GithubHelp logo

Comments (3)

pkozlowski-opensource avatar pkozlowski-opensource commented on July 20, 2024

While we could make this change, there is a broader question about pure pipes usefulness with signals. Our thinking was that most of the pure pipe usages would be replaced by computed. Would this work for your case? If not, could you share more about your particular scenario?

from angular.

jnizet avatar jnizet commented on July 20, 2024

@pkozlowski-opensource

A computed would certainly work.
I think pipes are a somewhat easier way of reusing data transformation logic in templates than having to expose a computed signal inside the components.

Let's imagine that the date pipe uses a globally configured signal holding the timezone or the locale, or the preferred pattern. I prefer having to import DatePipe and be able to use {{ someObject().someDate | date }}, than having to add

formattedDate = computed(() => formatDate(someObject().someDate));

to the component.

This is even truer if the pipe is used repeatedly inside a for loop for example.

If Angular was designed from scratch around signals now, my guess is that pipes would not exist. But since they do, I think they should work in the most intuitive way, and be consistent with the rest of the framework, where a signal change causes the template to be refreshed.

TBH, I don't have a real specific use-case here. This issue came out in a question in the Angular Discord, where someone else asked whether updating a signal would cause the pipe to be reexecuted.

from angular.

pfeileon avatar pfeileon commented on July 20, 2024

Well, I guess what you'd really like to do is something like this: signal() | mappingFunction and all you have to do is provide a source signal and a pure function. The computed part is done for you.

from angular.

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.