Contentful Personalization & Analytics
    Preparing search index...
    interface SignalFns {
        batch: <T>(fn: () => T) => T;
        computed: <T>(fn: () => T, options?: SignalOptions<T>) => ReadonlySignal<T>;
        effect: (fn: EffectFn, options?: EffectOptions) => () => void;
        untracked: <T>(fn: () => T) => T;
    }
    Index

    Properties

    batch: <T>(fn: () => T) => T

    Type declaration

      • <T>(fn: () => T): T
      • Combine multiple value updates into one "commit" at the end of the provided callback.

        Batches can be nested and changes are only flushed once the outermost batch callback completes.

        Accessing a signal that has been modified within a batch will reflect its updated value.

        Type Parameters

        • T

        Parameters

        • fn: () => T

          The callback function.

        Returns T

        The value returned by the callback.

    computed: <T>(fn: () => T, options?: SignalOptions<T>) => ReadonlySignal<T>

    Type declaration

      • <T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>
      • Create a new signal that is computed based on the values of other signals.

        The returned computed signal is read-only, and its value is automatically updated when any signals accessed from within the callback function change.

        Type Parameters

        • T

        Parameters

        • fn: () => T

          The effect callback.

        • Optionaloptions: SignalOptions<T>

        Returns ReadonlySignal<T>

        A new read-only signal.

    effect: (fn: EffectFn, options?: EffectOptions) => () => void

    Type declaration

      • (fn: EffectFn, options?: EffectOptions): () => void
      • Create an effect to run arbitrary code in response to signal changes.

        An effect tracks which signals are accessed within the given callback function fn, and re-runs the callback when those signals change.

        The callback may return a cleanup function. The cleanup function gets run once, either when the callback is next called or when the effect gets disposed, whichever happens first.

        Parameters

        • fn: EffectFn

          The effect callback.

        • Optionaloptions: EffectOptions

        Returns () => void

        A function for disposing the effect.

    untracked: <T>(fn: () => T) => T

    Type declaration

      • <T>(fn: () => T): T
      • Run a callback function that can access signal values without subscribing to the signal updates.

        Type Parameters

        • T

        Parameters

        • fn: () => T

          The callback function.

        Returns T

        The value returned by the callback.