Signals and RxJS Together: toSignal, toObservable and rxResource

Angular 14 min min read Updated: Nov 16, 2026 Intermediate
Signals and RxJS Together: toSignal, toObservable and rxResource
Intermediate Topic 4 of 5

Why Interop?

Angular's HTTP client, router and forms still give you observables, while your UI state is in signals. The @angular/core/rxjs-interop package connects both worlds.

toSignal: Observable to Signal

typescript import { toSignal } from '@angular/core/rxjs-interop'; @Component({ selector: 'app-users', template: ` @for (u of users(); track u.id) { <p>{{ u.name }}</p> } <p>Total: {{ users().length }}</p> `, }) export class Users { private http = inject(HttpClient); users = toSignal(this.http.get<User[]>('/api/users'), { initialValue: [] }); }

toSignal subscribes immediately and unsubscribes automatically. Give an initialValue or the signal can be undefined before the first value.

toObservable: Signal to Observable

typescript import { toObservable } from '@angular/core/rxjs-interop'; query = signal(''); results = toSignal( toObservable(this.query).pipe( debounceTime(300), switchMap(q => this.http.get<Product[]>('/api/products', { params: { q } }))), { initialValue: [] });

The resource API

A resource loads async data that depends on signals. When the request signal changes, the resource reloads and gives you value, isLoading and error as signals.

typescript import { resource, signal } from '@angular/core'; @Component({ selector: 'app-user-detail', template: ` <input type="number" [value]="userId()" (input)="userId.set(+$any($event.target).value)"> @if (user.isLoading()) { <p>Loading...</p> } @if (user.error()) { <p>Could not load user.</p> } @if (user.hasValue()) { <h3>{{ user.value()!.name }}</h3> } <button (click)="user.reload()">Reload</button> `, }) export class UserDetail { userId = signal(1); user = resource({ params: () => ({ id: this.userId() }), loader: async ({ params, abortSignal }) => { const res = await fetch(`/api/users/${params.id}`, { signal: abortSignal }); if (!res.ok) throw new Error('Request failed'); return (await res.json()) as User; }, }); }
Naming note: In some Angular versions the first option of resource was called request instead of params. If your editor complains, check the guide for your version at angular.dev. The idea is the same.

rxResource and httpResource

typescript import { rxResource } from '@angular/core/rxjs-interop'; import { httpResource } from '@angular/common/http'; // 1. rxResource: loader returns an Observable user = rxResource({ params: () => ({ id: this.userId() }), stream: ({ params }) => this.http.get<User>(`/api/users/${params.id}`), }); // 2. httpResource: easiest for HTTP GET product = httpResource<Product>(() => `/api/products/${this.productId()}`);
html @if (product.isLoading()) { <p>Loading...</p> } @else if (product.error()) { <p>Failed to load</p> } @else { <h3>{{ product.value()?.name }}</h3> }
Resource signalMeaning
value()The data (or undefined)
isLoading()A request is running
error()The error, if any
status()idle, loading, resolved, error and more
reload()Run the request again
Which to choose? Use httpResource for simple GET requests, rxResource when you already have RxJS logic and the normal HttpClient plus toSignal for fire-and-forget calls such as POST.

Conclusion

toSignal and toObservable bridge RxJS and signals. Resources (httpResource, rxResource) turn async loading into signals with built-in loading and error states.

Quick Summary: toSignal(obs$), toObservable(sig), resources for signal-driven loading.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators