Skip to content

Signal computed not refreshed #54859

@Rebolon

Description

@Rebolon

Which @angular/* package(s) are the source of the bug?

common, core

Is this a regression?

No

Description

The new Signal Api has a computed function that expect to be reactive, based on encapsulated Signals.
I have some use case here it's not refreshed. I expected toSignal to be the root of the problem, but it appears that it also failed with simple signal value.

  usersSignalStore: WritableSignal<string[]> = signal(['first']);
  usersCountCompute = computed(() => {
    const users = this.usersSignalStore();
    return users.length;
  });

usersSignal is note recomputed when usersSignalStore is modified.

In a template, i can do {{usersSignalStore().length}} and it will work. But using {{ usersCountCompute() }} will display 1 at first time, but will never be refreshed.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-fdzu8r

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

"dependencies": {
    "@angular/animations": "^17.2.0",
    "@angular/common": "^17.2.0",
    "@angular/compiler": "^17.2.0",
    "@angular/core": "^17.2.0",
    "@angular/forms": "^17.2.0",
    "@angular/platform-browser": "^17.2.0",
    "@angular/router": "^17.2.0",
    "rxjs": "^7.8.1",
    "tslib": "^2.5.0",
    "zone.js": "~0.14.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.2.0",
    "@angular/cli": "^17.2.0",
    "@angular/compiler-cli": "^17.2.0",
    "typescript": "~5.3.0"
  },

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions