NG.II · Angular 22 practice question
A developer is using an `effect` hook in a component to fetch user data asynchronously. If they read a signal inside the asynchronous block (after `await`), what will happen to the signal's dependency tracking?
effect(async () => {
await apiService.fetchUser();
console.log(userSignal());
});
Check answer and explanation
Correct answer: The signal read will not be tracked because the reactive context is lost after the `await` operation.
Explanation
The signal read will not be tracked because the reactive context is lost after the `await` operation.
Common trap
The assertion that 'the signal read will still be tracked, as effects maintain reactivity across async boundaries' is incorrect because the reactive context is strictly synchronous; furthermore, the claim that 'the effect will automatically re-run whenever the signal changes, regardless of where it is read' is misleading as reactivity depends on tracking, not just re-running.
Source: Angular docs: guide/signals/overview — Reactive context and async operations
Checked against the cited text on 2026-11-25.