toSignal() (stable, @angular/core/rxjs-interop) chuyển một Observable thành signal — cách phổ biến nhất để dùng RxJS/HttpClient data trong component signal-based.
user = toSignal(this.http.get<User>(`/api/users/${id}`), { initialValue: null })
userName = computed(() => this.user()?.name ?? "Loading")resource() / httpResource() (experimental) tạo resource phản ứng theo params, expose sẵn value, isLoading, error, status, reload — gần với React Query hơn.
userResource = httpResource<User>(() => `/api/users/${userId()}`)Khác biệt: toSignal chỉ là cầu nối Observable→signal (tự lo loading/error); resource quản lý cả lifecycle.
Production hiện nên dùng toSignal (stable); resource còn experimental — cần đánh giá cancellation/caching trước khi adopt.
toSignal() (stable, @angular/core/rxjs-interop) converts an Observable into a signal — the most common way to use RxJS/HttpClient data in signal-based components.
user = toSignal(this.http.get<User>(`/api/users/${id}`), { initialValue: null })
userName = computed(() => this.user()?.name ?? "Loading")resource() / httpResource() (experimental) create a resource that reacts to params and exposes value, isLoading, error, status, reload — closer to React Query.
userResource = httpResource<User>(() => `/api/users/${userId()}`)Difference: toSignal is just an Observable→signal bridge (you handle loading/error); resource manages the whole lifecycle.
Use toSignal (stable) in production today; resource is still experimental — evaluate cancellation/caching before adopting.