@kayahr/signal
    Preparing search index...

    Function toSignal

    • Converts an observable to a signal getter.

      The returned getter always has a value because the observable is required to emit synchronously during subscription. When the observable errors, the getter throws that failure normalized to an Error.

      The returned getter can be manually disposed and is additionally registered on the active scope, if there is one. Observable completion keeps the last signal value and does not dispose the conversion automatically.

      Type Parameters

      • T

      Parameters

      • observable: Subscribable<T>

        The observable to subscribe to.

      • options: ToSignalOptions<T, never> & { initialValue?: undefined }

        Requires a synchronous first emission.

      Returns DisposableGetter<T>

      A getter for the latest emitted value.

      SignalError - When requireSync is set and the observable does not emit during subscription.

    • Converts an observable to a signal getter.

      The returned getter yields the latest observable value. If requireSync is set, then the conversion throws unless the observable emits synchronously during subscription. When the observable errors, the getter throws that failure normalized to an Error.

      The returned getter can be manually disposed and is additionally registered on the active scope, if there is one. Observable completion keeps the last signal value and does not dispose the conversion automatically.

      Type Parameters

      • T

      Parameters

      • observable: Subscribable<T>
      • Optionaloptions: ToSignalOptions<T, never> & {
            initialValue?: undefined;
            requireSync?: undefined;
        }

        Optional conversion behavior overrides without an explicit initial value.

      Returns DisposableGetter<T | undefined>

      A getter for the latest emitted value.

    • Converts an observable to a signal getter.

      The returned getter yields the configured initial value until the observable emits for the first time. When the observable errors, the getter throws that failure normalized to an Error.

      The returned getter can be manually disposed and is additionally registered on the active scope, if there is one. Observable completion keeps the last signal value and does not dispose the conversion automatically.

      Type Parameters

      • T
      • Init

      Parameters

      • observable: Subscribable<T>

        The observable to subscribe to.

      • options: ToSignalOptions<T, Init> & { initialValue: Init; requireSync?: undefined }

        Optional conversion behavior overrides with an explicit initial value.

      Returns DisposableGetter<T | Init>

      A getter for the latest emitted value.