Connecting Signals and RxJS
Bridge signals and observables with interop.
Connecting Signals and RxJS is a free Angular Academy lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, and your progress syncs across the web and the CoddyKit app. The Angular Academy course includes 4 lessons in total.
Two Reactive Worlds
Angular apps mix signals (synchronous, pull-based) and RxJS Observables (asynchronous, push-based streams). The @angular/core/rxjs-interop package bridges them with toSignal and toObservable.
toSignal Basics
toSignal() subscribes to an Observable and exposes its latest value as a read-only signal. It unsubscribes automatically when the injection context is destroyed.
import { toSignal } from '@angular/core/rxjs-interop';
clock = toSignal(interval(1000), { initialValue: 0 });
// read in template: {{ clock() }}initialValue and Sync Reads
Observables may not emit synchronously, so a signal needs a starting value. Provide initialValue, or use requireSync: true when the source is guaranteed to emit immediately (like a BehaviorSubject).
value = toSignal(this.behaviorSubject$, { requireSync: true });Replacing the async Pipe
toSignal often replaces the async pipe. Instead of data$ | async you read data() directly, which composes cleanly with computed().
private http = inject(HttpClient);
users = toSignal(this.http.get<User[]>('/api/users'), { initialValue: [] });
count = computed(() => this.users().length);toObservable Basics
toObservable() turns a signal into an Observable that emits whenever the signal changes. Useful when you need RxJS operators like debounceTime or switchMap.
import { toObservable } from '@angular/core/rxjs-interop';
query = signal('');
query$ = toObservable(this.query);Debounced Search Pipeline
Combine both directions: a signal feeds toObservable, RxJS debounces and switches to an HTTP call, and toSignal turns results back into a signal.
query = signal('');
results = toSignal(
toObservable(this.query).pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap(q => this.api.search(q))
), { initialValue: [] }
);Injection Context
Both helpers need an injection context (they manage subscriptions tied to a lifecycle). Call them as field initializers or pass an explicit injector if calling later.
constructor() {
this.data = toSignal(this.source$); // ok: in constructor
}Error Handling
If the source Observable errors, toSignal rethrows on read. Handle errors inside the pipeline with catchError so the signal keeps a usable value.
results = toSignal(
toObservable(this.query).pipe(
switchMap(q => this.api.search(q).pipe(catchError(() => of([]))))
), { initialValue: [] }
);toObservable Timing
toObservable uses an effect under the hood, so emissions are delivered on the next microtask, not synchronously. Rapid signal changes are coalesced to the latest value.
When To Use Which
Reach for toObservable when you need time-based or higher-order operators. Reach for toSignal to consume any stream in templates and computed read models without manual subscription.
Cleanup Is Automatic
Both helpers tie their subscription to the injection context's lifecycle. When the component or service is destroyed the subscription is torn down, preventing leaks without manual unsubscribe().
Quick Check
Check your interop knowledge.
Recap
You bridged signals and RxJS: toSignal consumes streams as read-only signals (with initialValue/requireSync), and toObservable exposes signals as streams for RxJS operators. Subscriptions clean up automatically via the injection context.
Learn HTML with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 38
- Lessons
- 144
Frequently Asked Questions
Is the “Connecting Signals and RxJS” lesson free?
Yes — any 3 lessons of the Angular Academy learning path, including “Connecting Signals and RxJS”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The Angular Academy course includes 4 lessons in total.
What will I learn in “Connecting Signals and RxJS”?
Bridge signals and observables with interop. You practise Angular Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Angular Academy?
No prior experience is required. Angular Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.
How long does the “Connecting Signals and RxJS” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Angular Academy lesson?
Yes. Every Angular Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Signal Stores in Services
- Deriving State with computed
- Updating State Immutably
- Connecting Signals and RxJS