ToSignalOptions
Options for toSignal.
initialValue
unknownInitial value for the signal produced by toSignal.
This will be the value of the signal until the observable emits its first value.
requireSync
boolean | undefinedWhether to require that the observable emits synchronously when toSignal subscribes.
If this is true, toSignal will assert that the observable produces a value immediately upon
subscription. Setting this option removes the need to either deal with undefined in the
signal type or provide an initialValue, at the cost of a runtime error if this requirement is
not met.
injector
Injector | undefinedInjector which will provide the DestroyRef used to clean up the Observable subscription.
If this is not provided, a DestroyRef will be retrieved from the current injection
context, unless manual cleanup is requested.
manualCleanup
boolean | undefinedWhether the subscription should be automatically cleaned up (via DestroyRef) when
toSignal's creation context is destroyed.
If manual cleanup is enabled, then DestroyRef is not used, and the subscription will persist
until the Observable itself completes.
rejectErrors
boolean | undefinedWhether toSignal should throw errors from the Observable error channel back to RxJS, where
they'll be processed as uncaught exceptions.
In practice, this means that the signal returned by toSignal will keep returning the last
good value forever, as Observables which error produce no further values. This option emulates
the behavior of the async pipe.
equal
ValueEqualityFn<T> | undefinedA comparison function which defines equality for values emitted by the observable.
Equality comparisons are executed against the initial value if one is provided.