How do toSignal and toObservable help mix signals and RxJS?

Angular signals and change detection · Experienced

Model answer

toSignal turns an Observable into a signal, subscribing and unsubscribing for you, with an initial value or the requireSync option. toObservable turns a signal into an Observable that emits when it changes.

This lets you keep RxJS for streams, such as HTTP, debouncing or WebSockets, and use signals for the template and local state. A common pattern is a search box signal, toObservable, debounceTime and switchMap, then toSignal for the results.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions