Function unstable_createComputedArray

  • Experimental

    Creates a computed array signal in Alien Signals, deriving a reactive array from an original signal array.

    Type Parameters

    • I

      The type of the items in the input array.

    • O

      The type of the items in the output array.

    Parameters

    • arr: ISignal<I[]>

      Signal containing an array.

    • getGetter: (itemSignal: ISignal<I>, index: number) => () => O

      A function returning a getter for each item signal.

    Returns Readonly<O[]>

    A proxied array signal.

    const numbersSignal = createSignal([1, 2, 3]);
    const compArray = createComputedArray(numbersSignal, (itemSignal, i) => () => {
    return itemSignal.get() * 2;
    });