Title: Computed signal with current value as input · Issue #64022 · angular/angular · GitHub
Open Graph Title: Computed signal with current value as input · Issue #64022 · angular/angular
X Title: Computed signal with current value as input · Issue #64022 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? core Description I sometimes end up in situations that need the current state of a signal, but also depend on some other signal source. The real cases are of course...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? core Description I sometimes end up in situations that need the current state of a signal, but also depend on some other sig...
X Description: Which @angular/* package(s) are relevant/related to the feature request? core Description I sometimes end up in situations that need the current state of a signal, but also depend on some other sig...
Opengraph URL: https://github.com/angular/angular/issues/64022
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Computed signal with current value as input","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\ncore\n\n### Description\n\nI sometimes end up in situations that need the current state of a signal, but also depend on some other signal source. \n\nThe real cases are of course more complicated, but the fundamental problem is essentially this:\nLets say I have a boolean signal (coming from somewhere else). I also need to know if that signal has ever been true. This cannot to my knowledge be properly solved in the current system of signals, without really ugly hacks.\n\nSignals usually follow the principles of functional programming, but life is dirty, sometimes those ideals cannot be held. LinkedSignals were added to address some similar situations, but I don't see how this category of problems can be dealt with. \n\n### Proposed solution\n\nSomething like statefulComputed or similar would work. A type of signal that is like computed, but with the current value as input.\n\n```\nhasEverBeenTrue = statefulComputed((currentValue) => {\n if(booleanSource()) {\n return true;\n }\n\n return currentValue;\n})\n```\n\n### Alternatives considered\n\nIt is possible to do things like\n\n```\nhasEverBeenTrue = computed(() => {\n if(booleanSource()) {\n return true;\n }\n\n return untracked(this.hasEverBeenTrue);\n})\n```\n\nBut this feels like a grave violation of the basic principles of computed. A computed value should be dependent only on it's sources and always return the same result for the same sources. This just breaks that. \n\nThis can also be solved by using effects like this:\n\n```\nhasEverBeenTrue = signal(false);\n\nhasEverBeenTrueEffect = effect(() => {\n if(booleanSource()) {\n this.hasEverBeenTrue.set(true);\n }\n})\n```\n\nbut that is actively discouraged in the documentation, for good reasons.","author":{"url":"https://github.com/eliashakuni","@type":"Person","name":"eliashakuni"},"datePublished":"2025-09-24T10:20:43Z","url":"https://github.com/angular/angular/issues/64022"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dc75f5da-83b0-a12e-6cb7-0cc06156f2fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D83A:B53AF:3662F56:486016F:6B0209A8 |
| html-safe-nonce | 23b6ae97f181b1332287f7e3775dafcbcaa38c9d402b5a01b973ce1157af93af |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODNBOkI1M0FGOjM2NjJGNTY6NDg2MDE2Rjo2QjAyMDlBOCIsInZpc2l0b3JfaWQiOiIzOTEyNjgzNjg3Njg2MzEwMzEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e98ecb600641af83011aacd77179955cbe52fd1f5d3b6fab847c561b6a5f7ad9 |
| hovercard-subject-tag | issue:3448742525 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/64022/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0b7a88192286b31f8a6d777d5503350c357c8aed6d8d68ba2a8977631e536ec4/angular/angular/issues/64022 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0b7a88192286b31f8a6d777d5503350c357c8aed6d8d68ba2a8977631e536ec4/angular/angular/issues/64022 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? core Description I sometimes end up in situations that need the current state of a signal, but also depend on some other sig... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eliashakuni |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width