toObservable()
Converts a signal into an RxJS Observable that emits on change.
Syntax
toObservable<T>(source: Signal<T>, options?): Observable<T> Parameters
| Name | Type | Required | Description |
|---|---|---|---|
source | Signal<T> | No | The signal to observe. |
options | object | No | Supports a custom injector. |
Returns
Observable<T> — Observable that emits the signal value when it changes.
Examples
import { Component, signal } from '@angular/core';
import { toObservable } from '@angular/core/rxjs-interop';
import { debounceTime } from 'rxjs';
@Component({ selector: 'app-q', standalone: true, template: '' })
export class QComponent {
query = signal('');
query$ = toObservable(this.query).pipe(debounceTime(300));
}
Notes
Internally uses an effect to bridge the signal into a stream, so it must run
in an injection context. Emissions are delivered asynchronously and
deduplicated by the signal's equality. Useful to apply RxJS operators like
debounceTime or switchMap to signal-driven values.