Title: feat(core): unwrap resources into computed/effect and @resolved / @loading / @error / @idle · Issue #70202 · angular/angular · GitHub
Open Graph Title: feat(core): unwrap resources into computed/effect and @resolved / @loading / @error / @idle · Issue #70202 · angular/angular
X Title: feat(core): unwrap resources into computed/effect and @resolved / @loading / @error / @idle · Issue #70202 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? core, compiler, compiler-cli, language-service Description This is a proof of concept / discussion, not a finished design. I implemented a local experiment on an An...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? core, compiler, compiler-cli, language-service Description This is a proof of concept / discussion, not a finished design. I...
X Description: Which @angular/* package(s) are relevant/related to the feature request? core, compiler, compiler-cli, language-service Description This is a proof of concept / discussion, not a finished design. I...
Opengraph URL: https://github.com/angular/angular/issues/70202
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(core): unwrap resources into computed/effect and @resolved / @loading / @error / @idle","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\ncore, compiler, compiler-cli, language-service\n\n### Description\n\nThis is a **proof of concept / discussion**, not a finished design. I implemented a local experiment on an Angular fork to explore whether async readiness can become a first-class property of the reactive graph and of control flow, the same way Solid.js 2.0 made async a property of computations instead of a separate resource primitive.\n\nI am **not planning to open a PR**. The POC only exists to make the trade-offs concrete. The useful next step is a design discussion: which read sites should be legal, and what “not ready” means in each of them.\n\n**Inspiration:** [Solid.js 2.0](https://www.solidjs.com/blog/solid-2-0-rc-the-big-reveal) — async `createMemo`, `\u003cLoading>` as the UI boundary for “not ready”, and `isPending` / `latest` for in-flight vs stale-while-revalidate. Docs: [solid 2.0 async data](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/05-async-data.md).\n\nAngular already has an excellent `resource()` with statuses (`idle` | `loading` | `reloading` | `resolved` | `local` | `error`). What is still awkward:\n\n1. Templates must branch on `status()` / `hasValue()` everywhere a derived value is read.\n2. `computed()` that reads `resource.value()` is `T | undefined` and does not pause.\n3. `effect()` that reads a resource either runs too early or throws.\n4. Chaining resources needs `params: ({chain}) => chain(other)`, which does not compose through an intermediate `computed()`.\n\nRelated but different: #54032 asked for `computed(() => promise, {async: true})`. This proposal keeps `resource()` as the async source and focuses on **unwrapping** and **boundaries**.\n\n#### Reproduction\n\nThe StackBlitz compiles `@resolved` against vendored tarballs of the local fork (not public npm 22.1).\n\n- StackBlitz: https://stackblitz.com/github/RomainDood/demo-resolved-control-flow\n- Demo repo: https://github.com/RomainDood/demo-resolved-control-flow\n\nWhat to observe:\n\n1. **First paint / Reset** — `@idle` (no request yet).\n2. **Load Ada** — `@loading`, then name + chained greeting.\n3. **Reload** — previous name stays (SWR).\n4. **Load Grace** — new load, previous content is replaced after loading.\n5. **Error** — `@error`; the effect does not log.\n\n#### Source (if you want to inspect the POC)\n\nThe compiler + runtime changes live on my fork, not in the demo app:\n\n- https://github.com/RomainDood/angular/tree/feat/settled-computed-async-pending\n\nNo PR to `angular/angular` from me. Use that branch only if the idea is worth reading through.\n\n### Proposed solution\n\nKeep `resource()`. Add a small unwrap + a control-flow boundary whose names match resource statuses.\n\n```ts\nuser = resolved(this.userResource);\n\nfullName = computed(() => {\n const u = this.user(); // T, not T | undefined\n return `${u.first} ${u.last}`;\n});\n\neffect(() => {\n console.log(this.fullName()); // runs only when resolved\n});\n\ndetails = resource({\n params: () => this.fullName(), // waits until ready\n loader: ({params}) => fetchDetails(params),\n});\n```\n\n```html\n@resolved {\n \u003ch2>{{ fullName() }}\u003c/h2>\n} @loading {\n \u003cp>Loading…\u003c/p>\n} @error {\n \u003cp>Failed to load\u003c/p>\n} @idle {\n \u003cp>No request yet\u003c/p>\n}\n```\n\n**Compile-time, not runtime:** reading `fullName()` / `resolved()` in a template **without** an `@resolved` block is a **compilation error** (extended template diagnostic). The app does not boot and then throw.\n\n#### Open questions (more important than the POC choices)\n\nOnce a `computed()` waits for a resource to be resolved, **where is it legal to read it?** The POC picked one answer so the demo could run. That is not a recommendation.\n\n1. **`effect()`** — Allow the read, but run the callback only when the value is resolved? Forbid it and force `status()` / `hasValue()`? If allowed, what happens on `error` (skip, like loading, or surface the error)?\n2. **`linkedSignal()`** — Allow? Pause until ready? Keep the previous local value? Forbid, because a writable linked state plus `NotReady` is easy to get wrong?\n3. **`params` of another `resource()`** — Allow `params: () => this.fullName()` so composition goes through computed? Keep `chain()` as the only official path? If allowed: `idle` → downstream `idle`, `loading` → `loading`, `error` → `error`?\n4. **`afterRenderEffect` / other reactive consumers** — Same rules as `effect()`, or stricter?\n5. **Templates outside `@resolved`** — The POC is a **compile-time error**, not a runtime throw. Is that the right default, or should it fail at runtime / be allowed with manual branching?\n6. **Nested `computed()`** — If `greeting` reads `fullName` which reads `resolved(user)`, does the whole chain become async? (POC: yes.)\n7. **Reload / SWR** — Does `reloading` still produce `T` so effects and the main branch keep running, or is reload “not ready” again?\n\nPOC semantics we used *only to have something runnable*:\n\n| Resource status | `resolved()` | Template | `effect` / `params` |\n| --- | --- | --- | --- |\n| `resolved` / `local` | `T` | main branch | run |\n| `reloading` | previous `T` (SWR) | keep main | run |\n| `idle` | `Idle` | `@idle` (falls back to `@loading` if omitted) | skip / idle |\n| `loading` | `NotReady` | `@loading` | skip / wait |\n| `error` | throw `resource.error()` | `@error` | skip (effect) / error (params) |\n\nOther POC notes, also open:\n\n- No public `computedAsync`. A normal `computed()` that reads `resolved()` becomes async and pauses.\n- Template reads of those values **without `@resolved` are a compile-time error**, not a runtime error.\n- `@loading` / `@error` reuse the same tokens as `@defer`, but attach to `@resolved`. `@idle` is `@resolved`-only.\n\nAgain: **no PR from me**. If the team wants to explore this, the open questions above matter more than the particular API I wired in the fork.\n\n### Alternatives considered\n\n1. **Keep branching on `status()` / `hasValue()`** — works, but every derived `computed` and every template repeats the same state machine. Easy to read `value()` too early.\n2. **`@if (resource.hasValue())`** — loses a first-class loading/error/idle slot and does not compose through `fullName` / `greeting`.\n3. **`params: ({chain}) => chain(other)` only** — good for resource-to-resource, not for `computed` in the middle or for effects.\n4. **Async `computed(() => promise)` (#54032)** — a different model (computed *is* the fetch). This POC keeps `resource()` as the fetch primitive and makes the *graph* understand readiness.\n5. **A library / helper** — `resolved()` could be user-land; `@resolved` cannot. The interesting part is the compiler boundary + CD catching `Idle` / `NotReady` without going through `ErrorHandler`.\n\nHappy to adjust names, drop `@error` / `@idle`, or keep `chain()` as the only official composition path. The goal of this issue is to discuss whether the Solid 2.0-style “async is part of the graph” direction is something Angular wants to explore on top of `resource()`, and **which read sites should be allowed**.","author":{"url":"https://github.com/RomainDood","@type":"Person","name":"RomainDood"},"datePublished":"2026-08-14T05:45:50Z","url":"https://github.com/angular/angular/issues/70202"}
| 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:d668126f-1a6f-52aa-0436-bc520b6bb137 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8EF4:2AAD2E:2E9A993:3E3D361:6B01DEF4 |
| html-safe-nonce | beb130bab7c707d636176ac99a284fbc7347cea0ebfde5c83c641e1bb4a83750 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUY0OjJBQUQyRToyRTlBOTkzOjNFM0QzNjE6NkIwMURFRjQiLCJ2aXNpdG9yX2lkIjoiMzM1MzUxMjk3MDQ3ODAxODI5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c33eee459dfd680f6a63d41e762082c8c9af198f2a5783e8e69f485c9116e15a |
| hovercard-subject-tag | issue:5148722947 |
| 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/70202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd5d2c620a334bef39d877d1de86b60b434d897488f343e95577ac7f97981de0/angular/angular/issues/70202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd5d2c620a334bef39d877d1de86b60b434d897488f343e95577ac7f97981de0/angular/angular/issues/70202 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? core, compiler, compiler-cli, language-service Description This is a proof of concept / discussion, not a finished design. I... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RomainDood |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width