Code Monkey home page Code Monkey logo

Comments (7)

pkozlowski-opensource avatar pkozlowski-opensource commented on May 3, 2024 3

Hi, booleanSignal i being read in both cases. && operators have to read and evaluate both conditions.
computed(() => this.boolean && this.booleanSignal())

This is not the case - if the first condition is false, the subsequent expression will not be evaluated: https://stackblitz.com/edit/vitejs-vite-gy878w?file=main.js&terminal=dev

from angular.

alxhub avatar alxhub commented on May 3, 2024 3

In that sense, this is "working as intended" from an Angular perspective. However, it does raise the question of whether computed prohibit (or perhaps warn about) the degenerate case of no dependencies?

from angular.

pkozlowski-opensource avatar pkozlowski-opensource commented on May 3, 2024 1

Are you speaking in terms of like, the language service or compiler giving a warning/error? If so, I think that would be nice.

It can't be compiler, any potential warning would have be runtime

from angular.

YanGeruch avatar YanGeruch commented on May 3, 2024

angular bug

from angular.

pkozlowski-opensource avatar pkozlowski-opensource commented on May 3, 2024

this is very unintuitive behaviour and shouldn't work like this when documentation states ant computed signal will recompute when signal inside changes.

This should be nuanced with the statement that "computed signal will recompute when accessed signal inside changes". In your second example there is no signal read at all at we were considering a warning in such cases.

from angular.

YanGeruch avatar YanGeruch commented on May 3, 2024

this is very unintuitive behaviour and shouldn't work like this when documentation states ant computed signal will recompute when signal inside changes.

This should be nuanced with the statement that "computed signal will recompute when accessed signal inside changes". In your second example there is no signal read at all at we were considering a warning in such cases.

Hi, booleanSignal i being read in both cases. && operators have to read and evaluate both conditions.
computed(() => this.boolean && this.booleanSignal())

from angular.

msmallest avatar msmallest commented on May 3, 2024

However, it does raise the question of whether computed prohibit (or perhaps warn about) the degenerate case of no dependencies?

Are you speaking in terms of like, the language service or compiler giving a warning/error? If so, I think that would be nice.

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.