@tempots/dom

makeComputed() function

Creates a computed signal that depends on other signals and updates when any of the dependencies change.

Signature:

makeComputed: (fn: () => T, dependencies: Array<AnySignal>, equals?: (a: T, b: T) => boolean) => Computed

Parameters

Parameter

Type

Description

fn

() => T

The function that computes the value.

dependencies

Array<AnySignal>

The array of signals that the computed value depends on.

equals

(a: T, b: T) => boolean

(Optional) The equality function used to compare the previous and current computed values.

Returns: Computed

  • The computed signal.