AppleSauce
    Preparing search index...

    Function useObservableState

    • A hook that subscribes to an Observable and returns its current value.

      Unlike the standard useObservableState from observable-hooks, this hook will synchronously get the initial value if the Observable emits synchronously. This prevents an extra render when the Observable has an immediate value.

      If the Observable does not emit synchronously, the hook returns undefined for the initial render (unlike useObservableEagerState which throws).

      The observable is only subscribed to once - the subscription created during the initial probe is kept alive and reused, avoiding issues with cold observables.

      Type Parameters

      • TState

        State type.

      Parameters

      Returns TState

      The current state value, or undefined if no value has been emitted yet.

    • A hook that subscribes to an Observable and returns its current value.

      Unlike the standard useObservableState from observable-hooks, this hook will synchronously get the initial value if the Observable emits synchronously. This prevents an extra render when the Observable has an immediate value.

      If the Observable does not emit synchronously, the hook returns undefined for the initial render (unlike useObservableEagerState which throws).

      The observable is only subscribed to once - the subscription created during the initial probe is kept alive and reused, avoiding issues with cold observables.

      Type Parameters

      • TState

        State type.

      Parameters

      Returns TState | undefined

      The current state value, or undefined if no value has been emitted yet.