Function createComputed

  • Creates a computed Alien Signal based on a getter function. Computed signals are read-only and update automatically when their dependencies change.

    Type Parameters

    • T

      The type of the computed value.

    Parameters

    • fn: () => T

      A getter function returning the computed value.

    Returns () => T

    A computed signal.

    const count = createSignal(1);
    const double = createComputed(() => count() * 2);