Can you use async operations inside computed()?
No, you cannot.
computed() must be synchronous. It returns a value immediately, not a promise.
If you use async/await or fetch() inside computed(), Angular will throw an error or ignore the changes.
Why?
Because computed() is meant for instant calculations. It works like a formula: you enter numbers and immediately see the result. If there is a delay inside, the signal will not be able to track dependencies correctly.
What to do with async?
If you need to work with asynchronous data (e.g. HTTP requests), you use:
effect(), for side-effect async operationsRxJS(temporarily)- or load data into a
signalmanually:
ts
const user = signal<User | null>(null);
async function loadUser() {
const res = await fetch('/api/user');
const data = await res.json();
user.set(data);
}Conclusion: computed() is only for synchronous dependencies. Everything async goes through effects or is handled manually.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.