Angular · Middle · Question 9 of 75
How do you turn an Observable into a signal?
- ✓Correct answer:
toSignal(obs$, { initialValue: [] })from@angular/core/rxjs-interop - 2
signal(obs$) - 3
computed(() => obs$)
Explanation
toSignal subscribes immediately and unsubscribes when the injection context is destroyed. Without initialValue the signal type includes undefined until the first emission.